7

The Facebook XHP extension introduces what are basically XML literals (well, XHTML literals) to the PHP language, allowing syntax like the following:

$foo = <div>hello</div>;

$foo = <div>
       hello
       </div>;

$foo = 'hello';
echo <div>{$foo}</div>; // outputs <div>hello</div>

$foo = 'hello';
echo <div>{substr($foo, 0, 2)}</div>; // outputs <div>he</div>

The biggest problem is that I cannot find an IDE that supports this syntax without flagging it as a syntax error.

I'm told that Facebook generally uses vim or emacs for development but I'm hoping for a more full-blown IDE that supports this syntax. At present, Netbeans 6.9, 7.0 M2, and Zend Studio 8 all flag this syntax as an error even though it executes fine on PHP with the XHP extension enabled.

Suggestions for an editor or plugin to an editor that allows this to work without syntax errors?

Info about XHP: https://github.com/facebook/xhp/wiki

mjh_ca
  • 607
  • 4
  • 9
  • 1
    More than 3 years have passed since this question. I'm using **NetBeans IDE 7.4** - it still doesn't support XHP syntax. Nor I find a decent IDE that supports XHP syntax. – Manu Manjunath Dec 26 '13 at 07:02

6 Answers6

3

Try netbeans, go to Tools > Options find tab Miscellaneous > Files. Choose your Extension or click new. Remember insert ignored files pattern should be insert, if not you will get error syntax.

hendrathings
  • 3,720
  • 16
  • 30
2

At Facebook we sometimes use SublimeText or Textmate. Both somewhat inherently support XHP. They don't necessarily understand it, but they don't consider it invalid syntax. As far as I know no one at Facebook has built any extensions to IDEs to handle the syntax better, mostly likely because we do use

2

this thread is pretty old, but I hope this can help somebody else! I tried the code in aptana studio3 and works!

P.M
  • 2,880
  • 3
  • 43
  • 53
0

I just searched the JetBrains website for this feature (in PHPStorm): They say it is very complex to provide this and so it will not come soon ( http://youtrack.jetbrains.com/issue/WI-1208 ). I think that will be the same on all other major IDEs.

What comes into my mind: Emacs. I've just started to learn Emacs because of the possibility to extend it a very easy way, just for DSLs like XHP (which is indeed an embedded DSL). Here's a good tutorial for Emacs http://david.rothlis.net/emacs/howtolearn.html.

Weltraumschaf
  • 408
  • 4
  • 17
0

I doubt this will work with the Cloud9 IDE but they accept user given features all the time. I requested syntax highlighting for 2 languages, and now they are both supported. Give it a try.

Official site: https://c9.io/

Github site: https://github.com/ajaxorg/cloud9

Feature requests: http://support.cloud9ide.com/forums/20010046-feature-requests

cnotethegr8
  • 7,342
  • 8
  • 68
  • 104
0

I never used this extension I just pasted your code in a PHP page in PHPDesigner 7 and it did not considered it an error.

I just love this app: http://www.mpsoftware.com/

Try it and see if it suits your needs.

Antonio Louro
  • 528
  • 1
  • 5
  • 14