Viewed   124 times

I am using NetBeans IDE 8.0.1 for my PHP development.

I like the syntax check feature in netbeans. But the problem that I have is that it only works with files that have .php extension .

I am using a lot of php code in files with .html extension, and no php syntax checking is being available in NetBeans for those files.

Is it possible to enable php syntax checking for .html files?

 Answers

5

One hacky way to do that:

  • go to Tools|Options|Miscellanous
  • select Files tab
  • from File extensions, select HTML
  • from Associated MIME type, select text/x-php5

Then NetBeans will consider all HTML files as PHP ones

Thursday, November 10, 2022
 
3

Update 2: As of Brackets 0.42, this is even simpler still:

  1. Open an .html file
  2. Change the status bar dropdown from HTML to PHP
  3. Open the dropdown again and click "Set as Default for .html Files"

Earlier update: You can now do this via a simple Brackets extension, without needing to modify the core code:

define(function (require, exports, module) {
    var LanguageManager = brackets.getModule("language/LanguageManager");
    var htmlLang = LanguageManager.getLanguage("html"),
        phpLang  = LanguageManager.getLanguage("php");
    htmlLang.removeFileExtension("html");
    phpLang.addFileExtension("html");
});
  1. Put this code in a file named main.js
  2. In Brackets, go to Help > Show Extensions Folder
  3. Create a new folder under user, and place the main.js file inside it
  4. Restart Brackets

Here's more info on writing Brackets extensions, if needed.


(old answer)

Unfortunately this is tricky in Brackets currently. Syntax highlighting is extensible in that you can assign new file extensions to a particular highlighting mode, but the ".html" extension is already in use by the plain-HTML highlighting mode.

Your best options are probably:

a) Pull Brackets from git and locally patch the languages.json file so that .html is interpreted as PHP instead. (You could do this in a regular installed build but it won't be fun, since that JSON file is baked into a giant minified blob). Running from a git copy isn't too hard though.

b) Rename all your files to reflect that they're not plain HTML. Brackets will automatically recognize ".phtml" for example, which seems like a more appropriate file extension anyway. (If there's some other extension that your templating system will use but Brackets doesn't recognize automatically, you can use this trick to register it as a PHP-type extension).

Sunday, November 20, 2022
 
rupello
 
4

a module which adds full less highlighting support can be downloaded from the following page: http://plugins.netbeans.org/plugin/32782/lesscss-module

i tested the module with netbeans 7.0 and it worked flawless.

Thursday, September 15, 2022
 
2

Currently there is no such thing developed to Zoom in/out Design View in Netbeans. As you mentioned, yes, there is a plugin to resize the Source Code window (here). All we can do is just hope for NetBeans to provide this feature to all its users in its next update.

Monday, December 12, 2022
 
5

The action you are referring to is called "linting" and there are a number of plugins for Sublime that lint PHP files. As mentioned by Len_D, PHP Syntax Checker is one, but I'd actually recommend SublimeLinter for Sublime Text 2 instead. (There is a different version of SublimeLinter for ST3, but it's not backwards-compatible, and has a completely different architecture than the ST2 version, which is no longer officially supported.)

To install, first install Package Control if you haven't already, then restart Sublime. Open the Command Palette with CtrlShiftP and type pci to bring up Package Control: Install Package. Hit Enter, then type in sublimelinter, then hit Enter again to install. After installation is complete, restart ST2 again for good luck. To configure, first open Sublime Text 2 -> Preferences -> Package Settings -> SublimeLinter -> Settings-Default and copy its entire contents. Then, open Settings-User from the same sub-menu and paste the contents into it. You can now close Settings-Default. For proper syntax highlighting (to tell where the comments are), select JavaScript -> JSON from the option list in the lower right of the Sublime window.

Scroll down to line 36 in the "sublimelinter_executable_map" dict and add a blank line between the opening { and closing } braces. Find the full path to the php executable on your system by opening Terminal and typing which php. Copy the path and add an entry for "php" on the blank line you just made. For example, if the path is /opt/local/bin/php, the full section should look like this:

"sublimelinter_executable_map":
{
    "php": "/opt/local/bin/php"
},

Scroll down through the rest of the "sublimelinter_*" options and modify them to suit your preferences. The options after line 108 are most likely irrelevant for you, as they deal with linters for JavaScript, CSS, Python, etc. However, feel free to read through them in case you'd like to use SublimeLinter for other languages. Once you're done, save the file and you should be all set. SublimeLinter will display its messages according to the "sublimelinter" (line 13) and "sublimelinter_delay" settings (line 67) (increase the value to increase the delay between stopping typing and linter messages appearing). If you don't want this "live" linting, set "sublimelinter" to load-save, save-only, or false, depending on your preferences. I personally find live linting to be rather annoying...

And that's about it. Full documentation is available in the README. Please keep in mind that if/when you upgrade to Sublime Text 3 (which I highly recommend, by the way), you'll need to install and configure SublimeLinter3, which is a complete re-write of the plugin into a more modular architecture. As such, the base SublimeLinter package must be supplemented by a language-specific linter plugin like SublimeLinter-php. Please ensure you read the full documentation (yes, there's a lot, but it's worth it) to get everything running smoothly.

Good luck!

Tuesday, October 4, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :