1
votes

I'm dealing with PHP in XML, using NetBeans IDE 7.0.1; the problem is I'm having trouble getting NetBeans to understand what language(s) I'm working with (simultaneously).

For instance, HTML markup and inline PHP is highlighted and auto-completed appropriately when properly delimited by <?php tags, this however is only true with the .php extension.

If I try to use XML, it simply doesn't observe the PHP code as PHP (or anything besides a text node I'm assuming) This is true when a given file has the .xml extension.

If I change the extension to .php, as in the case of HTML, my inline PHP becomes recognized, but my XML starts behaving strangely (no recognition of matching node tags; the <?xml declaration isn't recognized, but that's expected; etc.)

Is there any way to get NetBeans to cleanly interpret a mixed file of PHP and XML based on tag delimitation?

I tried using ASP style tags <%, but those don't help the XML recognition when the file is .php anyways; when I switch it out to .xml, it doesn't matter what PHP delimiters I use, it just doesn't recognize any PHP.

To phrase my question differently, if NetBeans will inevitably fail, what IDE would one suggest?

2
I see a vote to close, but no explanation as to why; should I elaborate on some point?Dan Lugg
@BoltClock - Well, whoever answers this will be a "super user" in my books, gfa-ha-ha...Dan Lugg
That person has either never used NetBeans, or is adamant that all software-usage-related questions must be on Super User, even if programmers are the main users.BoltClock
@BoltClock - Yea, let's start forwarding all of our Visual Studio questions over there too. ".NET? C-Sharp my eye, that's software!"Dan Lugg
In any case, my go-to web development IDE is Aptana, which you could take for a spin. Except, you know, it's based on Eclipse, a direct competitor to NetBeans and everything...BoltClock

2 Answers

2
votes

In Netbeans, you can specify what mime type is associated with the file: Tools > Options > Miscellaneous > Files

However, you cannot change the mime type for .xml files. Changing the .php extension to be mime text/xml makes PHP files to simply use the XML formatting. No help there.

However, what I have gotten to work is specifying xhtml extensions to be type text/x-php5. Also, I had to disable shorttags for the project (File > Project Properties > Sources > Allow short tags). At a glance it seems to be working. If you gave me an example file of XML, I may be able to get a complete working solution.

Also, if you create a new extension type and associate it as text/x-php5, it may work. dxml (Dynamic XML?) pxml (PhpXML?) etc.


Edit: In the process of getting this to work, I overlooked simply disabling shorttags. In PHP files that have an XML declaration, you can get XHTML to work.

Also, I'm not sure that you can get all the schema validation stuff to work. But I do know syntax highlighting is good to go.

1
votes

To phrase my question differently, if NetBeans will inevitably fail, what IDE would one suggest?

I can't say much about NetBeans for sure as I've never used it for anything but Java desktop apps, but the Eclipse-based Aptana is my go-to IDE for web development. It supports plenty of languages (and even frameworks) out of the box. Syntax highlighting is a little sketchy, though, in that it uses an engine similar to TextMate, but it shouldn't bug out horribly on multilingual files.