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. Not really.. I already had someone else asking this and had a look at Espresso plugin development.

      First I don’t use Espresso (had a look two or three times and found it not to be a great tool). But second and more importantly: The plugin interface quite differs from Coda so I’d have to rewrite nearly everything, test it and so on (not mentioning having to do this every time I add a feature). Because of that I’m afraid this isn’t going to happen soon..

      1. Fair enough. I have been using TextWrangler for a while and every once in a while think about switching to Code or Espresso or some other hot new editor. Mostly for the intellisense features as I’m starting to use jQuery more and more.

        Your tools are great and something that’s definitely missing from other editors. You might just sway me over to Coda.

      1. Hi,

        I uninstalled the PHP and Web Toolkit, and the find function worked again, so it does seem related. However after reinstalling the PHP and Web Toolkit the find function still worked. I’m glad I can now perfectly use both.. :)

        Maybe something odd happened during installation of the plugin the first time?

  1. For some reason I get these messages when using ‘Tidy PHP’ or ‘Tidy CSS’:

    PHPTidy returned nothing
    Make sure the file has no errors, try using UTF-8 encoding.

    (or)

    CSSTidy returned nothing
    Make sure the file has no errors, try using UTF-8 encoding.

    The files are for sure UTF-8 encoding. I can’t get it to work on a single file. It was working before then started doing this all of the sudden.

    I love this plugin and use it all the time! I really want to get this working!

    1. Hi –

      late reply, but I was on holiday :)

      Okay:
      – Do the other functions work?
      – Could you send me one of the files (mario at chipwreck dot de)?

      I’m sure this can be fixed..:)

    1. The best would be if you send me the code via email (mario at chipwreck dot de), then I can look what goes wrong..

      And thanks for the hint, I’ll have a look at php beautifier.

  2. First off this is a great coda plugin. Love the way it organizes everything. One issue I came across right off the bat is the CSS minification totally breaks when you have absolute urls to background images like this:

    .rendButton {
    background:url(http://assets.impulsestudios.ca/site/v_sprite.png) 0 -958px repeat-x;
    }

    it removes the //assets.impulsestudios.ca/site/v_sprite.png) part. (I assume it has something to do with the minifier mistaking it for a comment. Anyways any site that uses a separate domain or CDN for distributing static content needs to use absolute urls.

    1. If you use quotes, minification works correctly:

      background:url('http://assets.impulsestudios.ca/site/v_sprite.png') 0 -958px repeat-x;

      For the next version I’ll have a look if there’s an update of the minifier, but until then quotes should be an easy (and syntactically correct) way around this.

  3. Mario, thanks for writing such a great plugin. I see that “Make PHP tidy more configurable” is on your todo list. I’d like to add two feature requests on that topic:

    1) don’t reformat IF/ELSE statements. My coding style is quite different than the one your implementation of TIDY does.

    Mine:
    if(some condition)
    {
    //true
    }
    else
    {
    // false
    }

    Yours:
    if
    (some condition
    {
    // true
    } else
    {
    // false
    }

    2) Add option to sort functions and classes alphabetically sort of like the way your CSS Tidy does.

    Keep up the great work.

    1. Hi –

      I’m afraid that’s not possible with the current version of PHPtidy (which isn’t developed by me). See also here: http://phptidy.berlios.de/

      About the IF/ELSE formatting: That seems a bit strange, I’ll have look there.

      – Your example should be achieved when using the setting “Always on new line”.
      – Additionally you can deselect “Fix statement brackets” to let PHPtidy leave your code alone.

      (But if I find another (open source) PHP beautifier with more possibilities I could integrate it as alternative – until now I haven’t found a good alternative..)

    1. I meant It is removing the “span” tags inside of “div”. Will changing value of both merge-div and merge-span be necessary?

      1. Hi –

        just checked HTML Tidy with configuration “default” – a span inside div-tag is not being removed.

        The “merge-div” and “merge-span” attributes are for nested divs OR spans, so they only remove divs inside divs (or spans).

        So if you’ve got further problems, try to reduce the HTML-file until it’s clear – or send it to me.

  4. Hi Mario, I have run into a few problems. I am trying to convert an illustrated book that is in greek and english. The book is about 130 pages.

    I have output the HTML from InDesign and when i load it in Coda, I see that it is “compressed”. One huge blob.

    1. When I try to tidy the entire file using your plugin, Coda hangs (I don’t blame it).

    2. If I break the file into chunks, it works ok, but it’s difficult to reassemble the document.

    3. Somewhere in all this, I’m losing some greek words. Not all, just some.

    I can send you the document but it’s about 20mb..

    Ideas welcome..

    David

  5. LOVE the plugin. My only gripe: IT seems to default to 4 spaces when you tidy php, rather than using the tab-width set in Coda (mine is two). Haven’t found a way around this.

    1. I see – this will be fixed in the next update.

      In the mean time you can fix it manually:

      – Go to (your user folder)/Library/Application Support/Coda/Plug-Ins/
      – Right click on “PhpPlugin.codaplugin” and select “Show Contents”
      – Open the file “Contents/Resources/phptidy-coda.php”
      – Change the string containing four spaces to two spaces on line 199:

      $indent_char = " ";

  6. it would be nice if you could assign different file extentions to be rendered as php, example in drupal themes the main file which is mostly php ends in .theme

    1. Hi –

      well this has nothing to do with my plugin, but here’s how it goes:

      In Coda, access “Settings”, then “Editor” and find “Custom Syntax Modes” at the bottom. There add a new mode, enter i.e. “theme” (without the dot) and select “PHP-HTML”, click “Ok” and done.

  7. When using CSS tidy, it removes the last comma from the last property in the class. Is there a way to tell the CSS tidy processor to keep that last comma?

    Thanks for the awesome plugin!

  8. When I run the php validation it gives me Chinese characters like this 乯⁳祮瑡砠敲牯牳⁤整散瑥搠楮‭ is there anyway to change it to english?

  9. Thank you so much for making the upgrade system automatic. The “download in a browser” method was painful. The new system is AWESOME!

    Thanks again :-)

      1. Alrighty thanks! not related to your plugin, but do you know if coda allows you to follow variables to classes in other files? Like if your calling a function or a class in a php file you can get a preview of where that class/function is coming from (similar to a stack trace)?

        1. No, unfortunately not. PHP support in Coda is just this: Syntax highlighting & auto complete (of predefined functions) & php documentation. For bigger projects or really professional PHP development currently the only choice is PHPStorm.

  10. I absolutely love this plugin especially the HTML Tidy feature. I was wondering if you have written one for Textmate as i am using this rather than Coda. The Textmate Html Tidy is terrible.

  11. Hello,

    Great plugin – very useful.

    Found a bug.

    When using the “strict whitespace rules” option of the JS Lint checker, it
    doesn’t seem to detect line indents correctly. For example I get “Expected ‘var’ to have an indentation at 5 instead at 1.”, but the var is already the 5th character (indented with spaces). It passes on the JSLint website, so must be a bug in either Coda or the plugin.

    The strict whitespace option is useful for detecting when you wanted spaces after, say, an “if” statement, but it becomes unusable when it reports every single line as being indented incorrectly!

    (Also, the title on the options page reads “JSHint” and not “JSLint”).

    Just a minor thing and possibly a bug in Coda rather than your plugin.

    Thanks,

    Mark

    1. Hi –

      yes that’s a known bug and is already fixed in the next beta (which is online now will be online in a few days).

      And JSHint is correct since the plugin uses JSHint, an updated version of JSLint – http://www.jshint.com

  12. Bug Report – PHP Tidy assumes code is valid and duplicates error and all following text into document.
    example
    – make a test php file
    – add the following lines

    Note the missing bracket in the 1st require_once.

    Do PHP Tidy
    Expected results – should IMHO validate first to check code CAN be tidied. Then error dialog shown OR code tidied.
    Actual Results – Errors messages inserted into existing text for the error AND all subsequent errors created by the initial error along with ALL the code following each error.

    The only way to get around this is to UNDO the inserts created by Tidy then fix the error, validate and then tidy.

    BTW thanks for making an awesome plugin.

    1. UGH php code insert stripped out :(
      add the following lines between the php start and end tags

      require_once (“testme.php”;
      require_once (“anothertest.php”);

      ;)

      1. That looks ugly.. very ugly.

        I’ll have a look. The validation is a great idea, I think I’ll implement this for the next release (the next beta is ready will be ready in a few days with this feature I assume).

        Thx!

    1. Have you tried it this:
      – same problem with different javascript files
      – checked that you haven’t accidentally selected a part of the text which is not valid javascript
      – make sure the file is utf-8?

      If that doesn’t help, you can also send me the file: mario at (name of this domain here).

        1. Strange – this means JSTidy did receive either no text or no options.

          So..
          – Please enable debug mode (Plug-ins > PHP & Web > Preferences: Advanced)
          – Open Console, try the same with two different files and send me the console lines which look like this:

          Coda[…] Warning [Coda PHP Toolkit] …. more stuff

          Thanks.

            1. That’s what I call unexpected :)

              But if you have time: Nevertheless check what caused the coda crash, in the console and mail it to me.. would be interesting.

              thx.

              1. Sad face, nothing relevant :( You might want to try on a clean Coda, put in 3.0, restart, then put in 3.1 and try JSTidy before starting Coda up again and see if you can replicate it that way

  13. Same here. After opening Preferences Windows I can’t close it. Every time I try to close it, it jumps to the javascript tab.

    1. Yes, if the server is configured with “short_open_tag=off“:

      – The XML declaration is valid on the server, where short_open_tag=off
      – ..but invalid for php on your mac (commandline), where short_open_tag=on

      -> You can write XML-Tags with PHP:
      [...] echo "";

      -> That means you have to rewrite your code
      -> But your php scripts will also run on a server with a different configuration

      If this is not possible, I can have look if I can add a configuration option for this.

      1. Hi Mario!

        I used the echo example on the files I was working on.

        Before it was still valid PHP, no? The server is setup to suppress error (was on a production server), so that may be the reason why the program didn’t give an error.

        1. Well.. if you *don’t* use short_open_tag=off, it gives you a syntax error – so it’s not always valid PHP, depends on the server config.

  14. Hello!

    When I tryed to use “JS Lint”, Coda crashes:

    NSInvalidArgumentException – *** -[NSCFString stringByAppendingString:]: nil argument

    NSExceptionHandlerExceptionRaiser (in ExceptionHandling) + 182
    objc_exception_throw (in libobjc.A.dylib) + 56
    +[NSException raise:format:arguments:] (in CoreFoundation) + 136
    +[NSException raise:format:] (in CoreFoundation) + 58
    -[NSString stringByAppendingString:] (in Foundation) + 111
    -[PhpPlugin doJsLint] (in PhpPlugin) + 1753
    -[NSApplication sendAction:to:from:] (in AppKit) + 112
    -[NSMenuItem _corePerformAction] (in AppKit) + 435
    -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] (in AppKit) + 174
    -[NSMenu _performActionWithHighlightingForItemAtIndex:] (in AppKit) + 49
    -[NSMenu performKeyEquivalent:] (in AppKit) + 314
    -[NSApplication _handleKeyEquivalent:] (in AppKit) + 581
    -[NSApplication sendEvent:] (in AppKit) + 4858
    -[NSApplication run] (in AppKit) + 917
    NSApplicationMain (in AppKit) + 574
    _start (in Coda) + 216
    start (in Coda) + 41
    0x00000002 (in Coda)

      1. With 3.1beta it’s work fine, thanks :)

        p.s. JSLint says that I have “Unsafe character” in _comments_ and I don’t find option to turn it off.

        1. Cool – another reason to release 3.1 soon :)

          The unsafe character alert has to do with the Javascript-call via Cocoa – usually happens if you use any special chars (äöü瀅). This will hopefully be fixed in 3.1 final. Until then just ignore it.

          1. I just used Cyrillic in comment (I’m russian), so in one file can be very many “errors” about this… It’s hard to ignore :)

            Thanks for very useful plugin!

  15. Why does this plugin constantly ask me to check for updates when I am already on the latest version?

    It’s super frustrating. Other than than I love the plug-in.

  16. Hi ChipWreck,

    When reformatting a minified css file with the following in it:
    ….button.primary{background:-webkit-gradient(linear,left bottom,left top,color-stop(0.5,#4d148c),color-stop(1,#9578ba));background:-moz-linear-gradient(center bottom,#4d148c 50%,#9578ba 100%);}…

    CSS Tidy on default setting, in the PHP & Web Toolkit Coda Plug-in, will remove needed spaces. Producing the following:

    button.primary {
    background:-webkit-gradient(linear,leftbottom,lefttop,color-stop(0.5,#4d148c),color-stop(1,#9578ba));
    background:-moz-linear-gradient(centerbottom,#4d148c50%,#9578ba100%);
    }

    Notice “left bottom” became “leftbottom”.

    ProCSSor does handle this situation correctly.

  17. is there a way to change the keyboard shortcut for HTML Tidy ? It’s conflicting with another shortcut for me.

    1. Hi –

      well, I could change it of course – but probably then someone else has problems :) So maybe I’ll add a configuration setting in the future.
      For now: Which other shortcut is conflicting?

  18. There’s a problem with your current JSHint integration. It ignores config headers and generates bad error reports.

    For this example JS file:
    /*jslint browser: true, onevar: true, undef: true, nomen: false,nomen: true eqeqeq: true, bitwise: true, regexp: true, newcap: true, immed: true */

    var foo = function () {
    this._stuff = ’10’;
    return this._stuff;
    };

    Your JSHint integration returns this:
    Problem at line 4 character 6: Unexpected dangling ‘_’ in ‘_stuff’.
    this._stuff = ’10’;
    Problem at line 5 character 13: Unexpected dangling ‘_’ in ‘_stuff’.
    return this._stuff;

    If you go to JSHint.com, and paste that JS code, it says:
    The code check passed.

    Somethings wrong hehe.

    Keep up the good work ^_^

    -Carlos

    1. It depends on the settings, there’s an option to “Disallow dangling _ in identifiers” (it’s not in the online version of jshint.com, but you can find it on jslint.com) – so it’s simply a personal preference on how strict the checks should be.

      1. I know, but check my code:
        (the previous post had a typo in the options comment, but which didn’t affect the outcome, I fixed it below)

        /*jslint browser: true, onevar: true, undef: true, nomen: false, eqeqeq: true, bitwise: true, regexp: true, newcap: true, immed: true */

        var foo = function () {
        this._stuff = ’10’;
        return this._stuff;
        };

        There’s a “config comment header” that should tell JSHint to ignore that error (nomen: false), but that config comment header is seemingly ignored by your JSHint integration.

        If you copy that code and paste it in JSHint.com, it will respect the config comment and validate my JS.

        1. Apparently, if I change the config header to say “/*jshint browser: true, etc” it will work.

          It’s a major change for anyone using the JSLint plugin hehe, because all of a sudden files will stop validating, and the default rules for validating also change. Maybe you should consider making it an option to use JSHint or JSLint.

          Thanks,
          Carlos

          1. Well that would be an option of course, but since JSHint is being actively developed (and JSLint is not), I’d prefer to continue to support JSHint only – which is compatible to JSLint. So what I’ll do is to look at the default settings. Which ones do you think are unnecessarily strict?

            1. Sorry, didn’t get notified about your reply.

              I think the most unnecessarily strict one is the one that prevents using “_” before names.

              The rest I can live with hehe.

  19. Hello,
    Every time I use the PHP validator, the pop-up window stays stuck open. I have to force quit Coda and restart. Kind of annoying, is it just me?

    1. I checked the debug mode… no more problems with that. Thank you sooooo much, this is an incredibly helpful tool, you’re awesome!

        1. The problem persists…
          When I start Coda, I get “PHP & Web Toolkit updated to 2.7” twice. I also have 2 “validate PHP” (the same option) in in the Plug0ins drop down.

          Lastly, when I do validate some PHP, the drop down saying it was valid or not either stays down and I need to restart Coda, or it saves automatically and closes the Coda window.

          All of this with the debug checkbox selected in preferences. Without the debug checkbox selected it just shows the frozen valid or invalid drop down.

          1. You have the plugin installed more than once.

            This happens if you download it and have an old version in the download folder: Safari automatically renames the file, so you end up with PhpPlugin.codaplugin, PhpPlugin-2.codaplugin, etc.

            To fix:

            – Quit Coda
            – Go to “(your user folder)/Library/Application Support/Coda/Plug-Ins”
            – Delete all “PhpPlugin.codaplugin”-files
            – Make sure that there are no previous versions in the Download-folder
            – Download again, install

    1. Disappeared in the current beta.

      Could you please enable “Debug mode” (in the plug-in preferences), open “Console” and try it again.

  20. Every time now I start Coda, the version 2.7 of the PHP plugin every time says that PHP plugin version 2.7 has been installed and that this message will be displayed only once. :)

  21. Great plugin
    I found some bug in JSLint, seems there is problem with utf-8 encoded polish strings, in this situation ‘ć’

    Fatal Error

    Error:
    Problem at line 3 character 22: Unclosed string.
    var answer = confirm(“Czy chcesz zresetowa

    1. Yes, I see, I will fix this in the next version but this might take some time..

      Until then you can either cut the characters and paste them in after validation or apply this bugfix (which in return might break the JS-Tidy function..):

      – Go to (your user folder)/Library/Application Support/Coda/Plug-ins
      – Right click on the “PhpPlugin.codaplugin” and choose “Show Contents”
      – Navigate to Contents/Resources
      – Open the file "js-call.sh" with a text editor (make a backup)
      – On the last line, at the end: Replace "$myc" with "$my"
      – Save file

      This should help..

        1. Even better!

          (In the future I’ll have to use another solution there, the bash-file is a workaround for problems when calling the OS X-JavaScript Interpreter – and the char conversion shouldn’t take place there..)

  22. Hey there, me again!

    I’ve some empty tags that must remain where they are and Tidy tips them off.

    O tried “new-empty-tags: span” in the Plugin Preferences, but it didn’t work.

    Any clue about that?

    Best and tks again for this awesome plugin!
    jw

    1. HTML tidy can unfortunately only keep empty P-tags (using “drop-empty-paras: no”) – for other tags I think there’s no possibility currently..

  23. There are some wierd things happening with the default HTML tidy, these are the things I have come across:

    * It changes © to the copy write symbol
    * It removed color:#FFF from inline styles in some div’s (needed for emails)
    * It removed the doctype declaration.

    This is the default config that comes up:

    // 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 4

    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

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

    1. Hi –

      I can’t reproduce it exactly, but I’ve got an idea :)

      Go the the plugin preferences, choose “Advanced” and check “Use internal” next to “HTML Tidy Binary”. And then try it again.

      (If it’s already checked, please send the Tidy version shown in the Preferences -> “About”, at the bottom.)

      mario

  24. Hi there Mario! Awesome plugin, thank you!

    Just wanted to let you know that it HTML Tidy rips off HTML5 tags such as or …

    Is there any way to update Tidy to make it “understand” those new tags? Are you aware of where we can find this update?

    Tks a lot!

    1. Hi –

      nice to hear!
      I assume the tags were also ripped of via WordPress – could you describe them without < or > ..?
      HTML-tidy development is quite.. slow. Visible for example in the very, very long list of feature requests, HTML 5 support among others.

      But there are possibilities to let HTML-Tidy learn unknown tags, I’ll have a look the next days.

      mario

        1. Okay, here’s how it goes:

          In the plugin preferences choose “custom” for the HTML Tidy configuration and 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

          Now it should look like this (Note that it’s two new lines, the line break is a bit unfortunate):

          I checked it with some HTML5-documents and the result was okay. It might that some of the tags are missing, I just hacked this together.
          Known error: If you use a datalist-tag and inside option-tags, these are removed.

          So this should help in the first place, but I’ll test it somewhat more and put it in the next release.

          mario

  25. I’ve been using your plugin for a while now. Much appreciated, especially for the consistent updates.

    Any chance a jQuery and/or CSS3 autocomplete plugin for Coda? :)

    1. Hi, well autocompletion is quite different from my plugin in the first place, but about CSS3 (which is partly already implemented in the latest Coda version), you’d better ask Panic.
      When it comes to jQuery. You can have a look here, but since I’m an avid Mootools user (as you might see on the rest of the website :) I haven’t tried it.

      Hope that helps.

Leave a Reply to Thomas Barrett 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.