Home » Php » Is there a PHP syntax checker for Notepad++?

Is there a PHP syntax checker for Notepad++?

Questions:

Is there a PHP syntax checker plugin for Notepad++?

Try NppExec plugin for Notepad++. Using it create a command to be something like this:

cmd.exe /K c:\your\path\to\php.exe -l "YOUR_FULL_FILE_NAME"


Instead of YOUR_FULL_FILE_NAME you should use appropriate Notepadd++ macro — I think it is $(FULL_CURRENT_PATH) but double check with NppExec manual (installs together with plugin). P.S. But any IDE will be better for sure (I’m using PhpStorm). If IDE is too heavy for your PC then look for php-oriented editors, like Blumentals RapidPHP etc (it’s lighter than full IDE but may have all really important features). Answer： As LazyOne said above, you can use NppExec which you can install using the plugin manager (Plugins>Plugin Manager>Show Plugin Manager) You’ll also need to have PHP installed. Lastly, the command I use to do PHP syntax checking with NppExec is "C:\Program Files (x86)\PHP\php.exe" -l$(FULL_CURRENT_PATH)


I recommend you find a true IDE (not a glorified text editor). I’ve used Notepad++ for years but it can’t do much beyond syntax highlighting.

I personally use PHPStorm (but it’s not free, it is very good though 😀 ). You could also use NetBeans or Eclipse.

I don’t like NetBeans, it’s too strict, has a tough time finding includes, and it’s slow. I dig N++ for its speed and simplicity. I have php installed on my PC really just to run validation. If you’re using N++ (or any other text editor) you can use the following Powershell script to batch check all of the files you’ve downloaded and are working on. Just fire up Powershell ISE, enter the correct path to check and PHP.exe path for your environment and the results get output to the ISE console.

cls
$pathToCheck = "C:\Users\BigDaddy\AppData\Local\Temp\fz3temp-1"$phpExePath = "C:\PHP\php.exe"

Get-ChildItem $pathToCheck -Filter "*.php" | foreach {$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName =$phpExePath
$pinfo.Arguments = "-l",$_.FullName
$pinfo.RedirectStandardError =$true
$pinfo.RedirectStandardOutput =$true
$pinfo.UseShellExecute =$false
$p = New-Object System.Diagnostics.Process$p.StartInfo = $pinfo$p.Start() | Out-Null
$p.WaitForExit()$output = $p.StandardOutput.ReadToEnd()$output += $p.StandardError.ReadToEnd()$output
}


I hope someone else finds this as useful as I have.

Cheers!

PHP can syntax check your file using the -l lint option. Install PHP (if you haven’t already) on your computer and use the Run function in Notepad++ and run a command like this:
cmd.exe /K "C:\Program Files\php-5.6.38-Win32-VC11-x64\php.exe" -l $(FULL_CURRENT_PATH)  Change the path to your install location. After running it via Run you are able to save it, give it a name and assign a custom keyboard shortcut. Breakdown of the command: • cmd.exe /K open a new Command shell which will stay open after executing • "C:\Program Files\php-5.6.38-Win32-VC11-x64\php.exe" launch php.exe • -l option of php.exe to use their lint service rather than executing • $(FULL_CURRENT_PATH) Notepad++ specific which gives the full path to the current open document