Coda PHP & Web Toolkit

  1. Download / Feedback •
  2. Help
  3. Coda Tips

AboutDownloadComments/Feedback

A Coda plugin aimed at PHP & Web development – not in active development.

Current version: 4.1 – Coda 1 and Coda 2

Features

  1. (Automatic) PHP syntax validation with jump to error and auto-save
  2. Clean up/reformat HTML, CSS, Javascript and PHP code (configurable)
  3. HTML, CSS and Javascript validation
  4. Minify Javascript and CSS
  5. Automatic check for updates
  6. It’s free (you can donate of course)

All features use the editor buffer (no need to save first) – Works with local and remote files – Written in Cocoa/ObjC.

General Preferences
Preferences for CSS
Preferences for Javascript
Validation with errors
Validation successful





Download

Download Coda PHP & Web Toolkit 4.1 »

Download Coda PHP & Web Toolkit 4.2 beta »

Sourcecode

https://bitbucket.org/mariofischer/php-web-toolkit/

Changelog »

Problems?

First have a look here » – if that doesn’t help, please write a comment below.

Enjoy using this plugin?

Great!
Just leave a comment or donate (via paypal) ».

For German users I can only recommend all-inkl.com (Partnerlink).

Planned Features

  • Apply some functions only to the selected area if desired (DONE – in the current beta)
  • Floating result windows/Growl-like notification/Use Growl (DONE – in the current beta)
  • Switch online validators more easy (DONE – in the current beta)
  • Rewrite curl methods in cocoa
  • Add configuration options for JSTidy
  • Automatically install updates
  • Use Coda 2 API for go to line (DONE – in the current beta)
  • Use Coda 2 API for automatic PHP validation before saving
  • Up next: Minify JS/CSS automatically on publishing
  • CSS minify: Check other minifier
  • Respect spaces per indent (in different cases)
  • PHP tidy: Preserve whitespaces, if possible
  • Minification: Upload .min.css or similar, if possible
  • Check new HTML5 tidy
  • Javascript execution directly via cocoa (improvement necessary)
  • Make PHP tidy more configurable (if possible)

795 Replies to “Coda PHP & Web Toolkit”

  1. Thanks Mario, I can’t believe I’ve been using Coda this long without it! One feature request: I regularly publish large data tables that genuinely benefit from html minification. Currently “tidy html” with the configuration “high compression” still doesn’t take out line breaks. Hmm… One might think one could do that as a supplementary step with Text > Processing > Remove Line Breaks, but that command actually just replaces line breaks with spaces (?!). I’ve complained about this to Panic but no fix in sight yet. So a “remove newlines” option in the “HTML Tidy” config would be handy. For something more aggressive (if you’re feeling generous) maybe you could incorporate kangax’s full-fledged minifier as a separate option: http://kangax.github.io/html-minifier/ The code is on github. It’s marked experimental but I’ve used it a lot over the past year and never had any problems. Would love to see it plugged in to Coda.

    1. Hi –

      yes, html tidy isn’t perfect of course – but for most cases it does the job. Removing newlines isn’t possible with HTML tidy (I think) – and since it’s a binary I can’t easily add more stuff :)

      But I think “Minify JS” should do the trick, just tried out some example files. It didn’t work in all cases though. Maybe as a workaround for some files.

      Kangax’s minifier: Looks good. Javascript is not the best language to integrate (at least via Cocoa/OSX..), but it should be possible.
      The only thing is: Maybe in 3 months, maybe in 3 weeks.. (I’ll have a look the next days how easy it would be to integrate)

      mario

    1. If there’s a good, free and open source formatter/validator for JSON or XML I can have a look of course. It depends a lot on the software and how much effort it’s to integrate it. So if you know some tool – just drop me a line here and I can have a look.

      1. Hi Mario,

        Hey thanks for the reply!

        I’d have to think the logic for the xml would be pretty much exactly as html, I’ve never really looked into making a Coda plugin before, maybe I’ll give it a try. I really don’t want to try to build all of what you’ve built though because it’s basically perfect and why reinvent the wheel.

        Would you care to collaborate on it? If you have an example of the html formatting I could check out I’d gladly contribute it to your project, xml at least. I’m pretty sure I could probably figure out the json part as well.

        Thanks! And again, awesome plugin!
        Travis

        1. Currently I use external tools which are executed from the plugin and the return value is being parsed.
          For example CSStidy (written in PHP), HTML tidy (as binary), JS-Tools (mostly in JS).

          I assume for XML and JSON there are already useful tools out there, but since now I haven’t looked for them…

          And thanks for your offer, let’s continue via email, just write to mario at chipwreck dot de.

  2. Hey,

    I’m trying to use the tidy HTML shortcut… but it doesn’t work??

    Anyone else had this issue?

    Can I change the shortcut at all?

    Thanks.

  3. How do I prevent Tidy HTML from stripping out CMS specific tags, such as:

    <perch:label …
    <perch:input …
    <perch:error …

    1. Select “custom..” as configuration for tidy and add the tags after “new-blocklevel-tags” or “new-inline-tags” – that shall do the trick.

  4. I have an issue where the html tidy strips out a closing / on my images. I need them to be there to not cause issues when using this code with xslt. Is there any setting in the custom section I can set or change that would stop it from stripping the closing /?

    Thanks!

    1. Therefore the document must be valid XHTML, then the closing / is syntactically correct.

      So if you use the following header, HTML Tidy won’t strip the closing / :






      ...


      ...


  5. Tidy HTML will erase list tags that don’t have text in them such as:
    i .. /i

    In this sample I am using an icon and do not want to add text.
    Cheers

  6. Awesome plugin mate! Thank you SO much!

    … While it worked. Not sure what I did, or if I did anyting, but suddenly all actions are greyed out in the PHP, CSS, JS and HTML sub-menus, i.e. I can’t do any more validations or tidying…

    Have also removed and reinstalled the plugin, but same problem. Using latest version 4.0, and it worked just fine yesterday!

    Any pointers?

    Thanks so much,

    Florian

    1. Make sure you have a file with more than just a few characters open – the menu items are only greyed out if there’s no active editor (or if the editor window contains no text (= less than some characters).

      Hope that helps – otherwise write a mail, then we’ll have to debug it.

            1. Okay..:

              Please enable “debug mode” in the advanced section of the plugin preferences, open “Console”, start using Coda 2 and copy all the lines from the console which contain “Coda PHP Toolkit” and send them to me ( mario at chipwreck dot de) – thx!

    1. I second this. This is by far my favorite plugin for Coda and frankly I wouldn’t use Coda if this plugin weren’t available. The only addition I would ask for is having the ability to choose the coding standard you want the “php tidy” to use. I’m currently inheriting a lot of projects where no standard was used so it would be nice to clean them all up using the psr-2 standard before I begin working on them. I’ve already installed php cs fixer and the php-md etc for Sublime, which isn’t nearly as nice as Coda. Would be great if the toolkit could run these tools when saving or upon command.

      1. PHPtidy doesn’t offer something like PSR-2, unfortunately. php-cs-fixer also came to my mind, I didn’t have a deeper look if and how difficult it would be to integrate.
        Currently (okay: the last months) I’ve got lots of other things eating my time, but along with html5-tidy (if possible with tabs) this is on the top of my todo-list.

  7. Works great. Thank you.

    The only thing I cannot modify through the preferences or the phptidy-coda.php file is the curly brace after functions going to a new line.

    Setting $curly_brace_newline = false; does not seem to be the answer.

    Also, occasionally and on files not authored in Coda, we see conditions dropping to a new line i.e.

    if/else newline ( condition )

    We correct this using a regexp .. and then next Tidy it will not happen.

  8. I have the “Validate on save” option picked for JavaScript files with the “Results in Floating Window” option. However, a new window is generated after each save (even for the same file). Could you just replace the contents instead?

  9. I love this plugin, but have found one annoyance. I use jQuery and jQueryUI extensively, and JSHint doesn’t like the jQuery syntax :-(. Any plans for adding that syntax so I don’t get a huge list of non-errors? Regardless, thanks for this!

  10. Greetings,

    I’ve been evaluating Coda 2 and frankly I decided to buy it based on how great this plugin is!

    Unfortunately, everything was working until I moved Coda 2 from Downloads to Applications. Now none of the features work in the plugin. For example when I minify JS I get “JSMinify returned nothing – Make sure the file has no errors, try using UTF-8 encoding.”

    I get this error if I try to tidy PHP as well. So I removed the plugin and re-installed it…and no dice. Still getting the error. Setting the file to UTF-8 didn’t help.

    Please help– this is such a great plugin I’m having withdrawal symptoms!
    Thanks,
    -NorthK

    1. This is what the console error shows:

      Application Specific Information:
      Performing @selector(doJsTidy) from sender NSMenuItem 0x10ba752c0
      *** multi-threaded process forked ***
      *** NSTask: Task create for path ‘/Applications/Mamp/bin/php/php5.4.4/bin’ failed: 22, “Invalid argument”. Terminating temporary process.

      1. Hi –

        this seems to be a problem with your php installation. Usually the plugin uses the default OSX php installation (/usr/bin/php). In your case it seems the PHP path is set to the MAMP installation. Please check in the plugin advanced preferences if you can set it back to /usr/bin/php.

        1. Hi Mario, you were right. For some reason the plugin didn’t like executing MAMP’s version of PHP. I must have changed the default setting and forgotten about it.

          It’s working now– thanks so much for your help and for writing a great plugin!
          -NorthK

  11. FOR CODA 2, When using VALIDATE HTML and TIDY HTML, there is error as below:

    NSInvalidArgumentException
    Reason:
    launch path not accessible

    How to work it out?

    1. Hi –

      this usually points to a problem with your php installation. Please check the php path in the plugin preferences (advanced). It is usually “/usr/bin/php”. Then open Terminal and enter the given path, like “/usr/bin/php -v” (without quotes) and check what the result is. If there’s an error message it hints to a defect php installation.

      1. When entered “/usr/bin/php -v” (without quotes) , It says:

        PHP 5.3.15 with Suhosin-Patch (cli) (built: Aug 24 2012 17:45:44)
        Copyright (c) 1997-2012 The PHP Group
        Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

        No error, does it mean no problem with my php installation? BUT I still got the error msgbox…

        1. Okay, your php installation looks fine – now please enable “debug mode” in the advanced section of the plugin preferences, open “Console”, start using “Validate HTML” and copy all the lines from the console which contain “Coda PHP Toolkit” and send them to me or copy them to a comment..

          1. Please see the code below:
            Coda 2[13383]: [Coda PHP Toolkit] Executing at path /Users/xu/Library/Application Support/Coda 2/Plug-ins/PhpPlugin.codaplugin/Contents/Resources/tidy with (
            “-config”,
            “/Users/xu/Library/Application Support/Coda 2/Plug-ins/PhpPlugin.codaplugin/Contents/Resources/tidy_config_check.txt”,
            “–newline”,
            LF,
            “-utf8”
            )
            13-1-29 上午8:42:31.376 Coda 2[13383]: Exception occurred: 0 ExceptionHandling 0x00000001009f3637 NSExceptionHandlerExceptionRaiser + 174
            1 libobjc.A.dylib 0x00007fff91c023f0 objc_exception_throw + 43
            2 CoreFoundation 0x00007fff8e99ae7c +[NSException raise:format:] + 204
            3 Foundation 0x00007fff90845cd2 -[NSConcreteTask launchWithDictionary:] + 409
            4 PhpPlugin 0x000000010ffcb46b -[CwPhpPlugin filterTextInput:with:options:encoding:useStdout:] + 594
            5 PhpPlugin 0x000000010ffcac62 -[CwPhpPlugin validateWith:arguments:called:showResult:useStdOut:alwaysWholeBuffer:] + 246
            6 PhpPlugin 0x000000010ffc6812 -[CwPhpPlugin doValidateHtml] + 261
            7 AppKit 0x00007fff8b7a5a59 -[NSApplication sendAction:to:from:] + 342
            8 AppKit 0x00007fff8b8db44c -[NSMenuItem _corePerformAction] + 406
            9 AppKit 0x00007fff8b8db13a -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 133
            10 AppKit 0x00007fff8b5c846f -[NSMenu _internalPerformActionForItemAtIndex:] + 36
            11 AppKit 0x00007fff8b5c82f7 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 135
            12 AppKit 0x00007fff8b8d4245 NSSLMMenuEventHandler + 342
            13 HIToolbox 0x00007fff89c0af0a _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1206
            14 HIToolbox 0x00007fff89c0a3d9 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 410
            15 HIToolbox 0x00007fff89c201bd SendEventToEventTarget + 40
            16 HIToolbox 0x00007fff89c56e89 _ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef + 443
            17 HIToolbox 0x00007fff89bfbc11 SendMenuCommandWithContextAndModifiers + 59
            18 HIToolbox 0x00007fff89bfbbc3 SendMenuItemSelectedEvent + 254
            19 HIToolbox 0x00007fff89bfba4f _ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 94
            20 HIToolbox 0x00007fff89bd7aab _ZL14MenuSelectCoreP8MenuData5PointdjPP13OpaqueMenuRefPt + 605
            21 HIToolbox 0x00007fff89bd70b8 _HandleMenuSelection2 + 565
            22 AppKit 0x00007fff8b7939c6 _NSHandleCarbonMenuEvent + 245
            23 AppKit 0x00007fff8b6b5b7f _DPSNextEvent + 2073
            24 AppKit 0x00007fff8b6b4ed2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
            25 AppKit 0x00007fff8b6ac283 -[NSApplication run] + 517
            26 AppKit 0x00007fff8b650cb6 NSApplicationMain + 869
            27 Coda 2 0x00000001000020f4 start + 52
            28 ??? 0x0000000000000002 0x0 + 2
            13-1-29 上午8:42:31.377 Coda 2[13383]: [Coda PHP Toolkit] Exception NSInvalidArgumentException launch path not accessible launch path not accessible

            1. This is strange..

              So:

              1. Please open Terminal and enter the following line (with quotes), press Return and send me the result:

              “/Users/xu/Library/Application Support/Coda 2/Plug-ins/PhpPlugin.codaplugin/Contents/Resources/tidy” -v

              2. Which Mac and which OS X-version do you use?

              thx!

                1. Okay, “Permission denied” isn’t correct. But I’ve currently no idea how this might happen..

                  Please try this command and check if it helps:

                  chmod +x “/Users/xu/Library/Application Support/Coda 2/Plug-ins/PhpPlugin.codaplugin/Contents/Resources/tidy”

                  1. It says:
                    chmod: “/Users/xu/Library/Application: No such file or directory
                    chmod: Support/Coda: No such file or directory
                    chmod: 2/Plug-ins/PhpPlugin.codaplugin/Contents/Resources/tidy”: No such file or directory

                    i dont know why? Because this file “/Users/xu/Library/Application Support/Coda 2/Plug-ins/PhpPlugin.codaplugin/Contents/Resources/tidy” is exist.

                    1. You should either use normal quotes (shift + 2) – or – put a backslash before each space, like this:

                      chmod /Users/xu/Library/Application\ Support/….

                    2. it helps!! Thank you so much! I’m sure you will fix this bug in the next upgrade:)

                    3. Glad we sorted it out, but this bug seems to be specific to your installation – in the plugin itself, the permissions are set correctly (checked this on different platforms).

  12. *FIGURED OUT A BUG CAUSE!*

    I was using “Minify CSS” on my site and my CSS3 animations stopped working in Firefox. I discovered the reason: Minifying using your plugin is adding quotes around the “animation name” property. This causes the animation to break (at least in FF 17.0.1 on my Mac).

    Thanks for a GREAT plugin!

    1. I see – yes, firefox doesn’t like the quotes (all other browsers work correctly with or without quotes).

      There’s already a patch for CSSMinify – it will be fixed in the next version.

  13. This is so awesome. I would not be able to work without it. Another thing I would not be able to work with out is SASS. I cleaned my SASS with the CSS tidyer. It broke it.

    Are there any plans for a SASS tidyier? Is that a bug that the CSS tidyer can even touch my SASS code?

    -Josh

    1. Hi –

      well the CSS tidy tool is only useful for (pure) CSS code – so it’s not a bug in that sense. The CSS tidy should only be used for CSS code, not SASS or LESS.

      Currently I don’t know if a SASS (or LESS) tidy tool even exists. If so – and if it’s open source and written in a language I can integrate – I can have a look.

  14. I thought the Coda 1.6 version did a ‘pack’ as well as ‘minify’ for js. Any plans on implementing that?

    1. JS minify is included, but a JS packer is nothing I plan to include. Because IMHO packing isn’t helpful – it just obfuscates JS code, makes it nearly impossible to debug and slower on the client side since it must be rebuild using “eval”.

  15. Hi!

    It seems that the “Notify with Growl” option gets unchecked sometimes, don’t know if this is related to restarting Coda 2 or restarting Growl or what.

    Using latest Coda 2 version, OSX 10.8 and the latest version of Growl from the Mac App Store.

    1. Hi-

      that happens if the plugin thinks Growl is not installed, which happens with the paid versions from the App Store (I don’t use them and have no way of tracking if they are installed..)

  16. I wish I found this earlier! Would have saved me hours of making sure I closed all of my tags and other menial work.

    1. Found it in

      ~/Library>Application Support>Coda 2>Plug-ins>PhpPlugin.codaplugin>Contents>Resources>jsbeautifier.php line 46

            1. Hi Mario,

              Yes, but you can add your own option and once HTML Tidy has processed, convert the spaces into tabs.

              I’ve seen implementation like this in other places :)

              Aaron

              1. Well the problem here is that I could only globally replace x spaces with a tab – so if you have for example a php-string with spaces that would also be a string with tabs afterwards, which isn’t what you want usually. Tidy is smarter and only looks at the whitespace outside of html- and php-tags and doesn’t touch your php code.

                I think in most of the cases the replacement would be fine – except in cases where it doesn’t and that could lead to serious problems (Let’s say you use php to write a file where spaces are necessary like CSV, EDIFACT etc.). (Of course the php-code to write text-files should be separate from the html-views, but as you might know, that’s not always the case :)

    1. Okay, I see – in HTML4/XHTML it’s not allowed to nest an H3-Tag inside an A-Tag, therefore HTML “corrects” this issue.

      This should not be a problem im HTML5 AFAIK, but HTML Tidy currently doesn’t natively support HTML5, unfortunately.

  17. Hi,

    Is there a way to set the Tidy HTML settings so that the only thing it changes is spaces and indents to clean up the nesting?

    Two examples of what it’s currently doing that I don’t want it to be able to edit:

    Deleting my “i”-tags”

    Changing…


    ...

    to…



    ...

    I’m using the default settings.

    Thanks!

    1. Hi –

      To keep “i”-tags use a custom configuration and add this line:
      logical-emphasis: no

      I can’t reproduce the other problem. If you have an “a”-tag, some lines of text and a closing “a”-tag HTML tidy doesn’t create two “a”-tags.. Maybe there’s another structural error in the file? Just remove everything else and test it with a minimal set of tags.

      1. Many thanks for getting back to me.

        How do I post code in your comments box without it being stripped out?

        I just created a new file with the simplest markup and ran HTML tidy. I can post the results of what it’s doing.

        Thanks!

  18. Hi,

    The Bootstrap framework uses the “i”-tag. Is there a way to update the HTML preferences so that Tidy won’t strip out them out?

    Many thanks for the awesome plug-in.

  19. Hey,

    The plugin broke after the last update. I’m getting this error in a alert box:

    NSInvalidArgumentException
    Reason:
    launch path not accessible

    Which sucks donkey-balls, because I like this plugin. I’ve already checked for duplicates, removed and re-installed, but no dice.

    1. Could you please enable debug mode in the plugin settings, open console and try again what causes this error. Then send me the logfile message regarding Coda PHP, via email to mario at chipwreck dot de.

  20. Hello,
    A very great plugin for a very great editor, thank you for your hard work!
    I have an idea for the minify options, but don’t know if it’s possible : save a css and a min.css file when you save your css in editor. This way, we always have both files in server and local, in case of problem.
    Is it possible? If yes, did you plan that?
    Thx.

    1. I’ll have a look if this is possible.

      UPDATE: Unfortunately that’s not possible with the current API – it provides a method to modify the file contents before publishing (that’s what I use currently), but no means of creating another file and publishing it.

    1. Hi –

      it seems WordPress has eaten some of your html-tags..

      HTML tidy is preconfigured to keep HTML5-tags, so new tags like “header” are kept if you use the predefined configurations (like “default”). If you prefer a custom configuration, add these lines:


      new-blocklevel-tags: article,aside,command,canvas,dialog,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,meter
      new-inline-tags: video,audio,canvas,ruby,rt,rp,time,meter,progress,datalist,keygen,mark,output,source,wbr

      Additionally there’s a new version of tidy for HTML5 being developed, which is experimental currently. I’ll check if the new tidy can be used in one of the next releases.

      1. Thanks Mario.

        Yep WP ate my code, basically I have things like [p] and [h2] tags inside the [a] to make large clickable areas. Frowned upon in the past, but allowed under HTML5.

      2. Hi,

        That does not work properly, tidy removes for example the “i” tag, tried adding it to the new-blocklevel-tags: section, no success. Also with pre-configured settings like “default” the “i” tags are removed.

        Example (from twitter bootstrap): ..

        1. That’s because “i” as tag is deprecated, use “em” instead.

          UPDATE: You can also use a custom configuration and add this line:
          logical-emphasis: no

          1. Hi Mario. Thanks a lot for this plugin, it’s really great. However, as some people points out, Bootstrap uses “i”-tags which are removed when using HTML Tidy. I see that you’re saying that one can add “logical-emphasis: no” but this is simply not working. I’ve tried to add it to multiple sections of the custom configuration but nothing happens.

            Should this work?

            // config file for Coda PHP Toolkit Tidy FORMAT script
            // http://www.chipwreck.de/blog/software/coda-php
            //
            // documentation is here: http://tidy.sourceforge.net/#docs
            // rev 5

            anchor-as-name: no
            doctype: auto
            drop-empty-paras: no
            fix-uri: no
            literal-attributes: yes
            merge-divs: no
            merge-spans: no
            numeric-entities: no
            preserve-entities: yes
            quote-ampersand: no
            quote-marks: no
            show-body-only: no
            indent: auto
            indent-spaces: 4
            tab-size: 4
            wrap: 0
            wrap-asp: no
            wrap-jste: no
            wrap-php: no
            wrap-sections: no
            tidy-mark: no
            logical-emphasis: no
            new-blocklevel-tags: article,aside,command,canvas,dialog,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,meter
            new-inline-tags: video,audio,canvas,ruby,rt,rp,time,meter,progress,datalist,keygen,mark,output,source,wbr

            // Change these only if you need to debug a problem with Tidy
            force-output: yes
            quiet: yes
            show-warnings: yes

Leave a Reply to Bruno Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.