Is there a PHP syntax checker for Notepad++?

前端 未结 6 1088
灰色年华
灰色年华 2021-02-05 01:23

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

Please don\'t answer \"Use another editor instead\"

相关标签:
6条回答
  • 2021-02-05 02:01

    I use Komodo Edit 7 (free version) which has a built-in php syntax checker. I dunno how robust it is, but it works fine for me. I’m not a pro web designer, but I like it better then Eclipse and Bluefish. Komodo is smaller than Eclipse and more stable than Bluefish (in my Win XP environment).

    0 讨论(0)
  • 2021-02-05 02:06

    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)
    
    0 讨论(0)
  • 2021-02-05 02:08

    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
    0 讨论(0)
  • 2021-02-05 02:10

    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 :D ). You could also use NetBeans or Eclipse.

    0 讨论(0)
  • 2021-02-05 02:14

    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).

    0 讨论(0)
  • 2021-02-05 02:25

    Adding to @LazyOne's answer: 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!

    0 讨论(0)
提交回复
热议问题