Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

The syntax coloring definition for PHP in Xcode (as of 5.0) is pretty poor:

  • probably some 30% of PHP keywords are missing from the definition and are not highlighted as such
  • PHP blocks in the middle of HTML tags, also within <script> and <style> blocks are not recognized
  • a big drawback for those who code with the short open tags, XCode doesn't support them (<? and <?=, in fact the latter is enabled irrespective of the short_open_tag setting as of PHP 5.4)
  • there is a strange glitch with PHP blocks in the form <?php ... with a single space after the opening tag: the token immediately after the space is not recognized as a PHP token unless you either add one more space or instead insert a new line

I made some modifications to the corresponding xclangspec files (which should be applied after each upgrade to XCode) that solve some of the problems above, but not all. I couldn't make it recognise my PHP insertions within <script> and <style>, plus I couldn't solve the single space glitch problem. Also, for some reason my modifications work slightly better when you mark your PHP files as HTML.

Obviously, short open tags can't be used in XML files, so I didn't even touch the XML syntax definitions, just PHP and HTML.


Answer: (since the question was closed): my patch that solves some of the problems above: https://github.com/crontab/xcode-php-patch

share|improve this question
    
I did not think Xcode supported php at all - just HTML and XML can you point to teh Apple docs where php is mentioned? –  Mark Oct 7 '12 at 20:57
    
@Mark I coudn't find any mentioning in the online documentation (strange, isn't it) but syntax coloring option is there, you can see it under Editor -> Syntax Coloring, or if you create/open a .php file. You can't even call it a "language support", just fancy coloring really ;) –  mojuba Oct 7 '12 at 21:06
1  
php with xcode is like hell. I use TextMate 2. It works great. –  Matthieu Riegler Oct 7 '12 at 21:43
    
@Matthieu Riegler can it do autocompletion and jump-to-definition for php? Xcode can't, and I'll dump it the moment I know some other IDE does these things. Oh, and does it handle short open tags correctly? –  mojuba Oct 7 '12 at 22:03
1  
Get a real PHP IDE like the free NetBeans or the paying but excellent PHPStorm. That said I fail to find a real practical question here. –  Gerry Oct 7 '12 at 22:07
show 2 more comments

closed as not a real question by Gerry, Mark, gentmatt, Stu Wilson, patrix Oct 8 '12 at 5:28

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.