Notepad ++ 是否有 PHP 语法检查器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6312023/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a PHP syntax checker for Notepad++?
提问by edt
Is there a PHP syntax checker plugin for Notepad++?
Notepad ++ 是否有 PHP 语法检查器插件?
Please don't answer "Use another editor instead"
请不要回答“改用其他编辑器”
采纳答案by LazyOne
Try NppExec pluginfor Notepad++. Using it create a command to be something like this:
试试Notepad++ 的NppExec 插件。使用它创建一个命令,如下所示:
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).
您应该使用适当的 Notepadd++ 宏而不是 YOUR_FULL_FILE_NAME - 我认为它$(FULL_CURRENT_PATH)
只是仔细检查 NppExec 手册(与插件一起安装)。
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).
PS但任何IDE肯定会更好(我正在使用PhpStorm)。如果 IDE 对您的 PC 来说太重,那么寻找面向 php 的编辑器,例如 Blumentals RapidPHP 等(它比完整的 IDE 轻,但可能具有所有非常重要的功能)。
回答by apocryphalauthor
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
正如 LazyOne 上面所说,您可以使用 NppExec,您可以使用插件管理器 ( Plugins>Plugin Manager>Show Plugin Manager
) 安装它。您还需要安装 PHP。最后,我使用 NppExec 进行 PHP 语法检查的命令是
"C:\Program Files (x86)\PHP\php.exe" -l $(FULL_CURRENT_PATH)
回答by Halcyon
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.
我建议您找到一个真正的 IDE(而不是美化的文本编辑器)。我已经使用 Notepad++ 多年了,但它除了语法高亮之外别无他法。
I personally use PHPStorm (but it's not free, it is very good though :D ). You could also use NetBeans or Eclipse.
我个人使用 PHPStorm(但它不是免费的,但它非常好:D)。您还可以使用 NetBeans 或 Eclipse。
回答by naphier
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.
添加@LazyOne 的回答:我不喜欢 NetBeans,它太严格了,很难找到包含,而且速度很慢。我挖掘 N++ 的速度和简单性。我在我的 PC 上安装了 php,只是为了运行验证。如果您使用的是 N++(或任何其他文本编辑器),您可以使用以下 Powershell 脚本批量检查您已下载并正在处理的所有文件。只需启动 Powershell ISE,输入正确的路径来检查您的环境的 PHP.exe 路径,结果就会输出到 ISE 控制台。
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!
干杯!
回答by Bhante-S
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).
我使用 Komodo Edit 7(免费版),它有一个内置的 php 语法检查器。我不知道它有多强大,但它对我来说很好用。我不是专业的网页设计师,但我比 Eclipse 和 Bluefish 更喜欢它。Komodo 比 Eclipse 小,比 Bluefish 更稳定(在我的 Win XP 环境中)。
回答by Jonas ?ppelgran
PHP can syntax check your file using the -l
lint option. Install PHP (if you haven't already) on your computer and use the Runfunction in Notepad++ and run a command like this:
PHP 可以使用-l
lint 选项对您的文件进行语法检查。在您的计算机上安装 PHP(如果您还没有)并使用Notepad++ 中的Run函数并运行如下命令:
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 Runyou are able to save it, give it a name and assign a custom keyboard shortcut.
更改安装位置的路径。通过Run运行它后,您可以保存它,为其命名并分配自定义键盘快捷键。
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
cmd.exe /K
打开一个新的命令外壳,执行后将保持打开状态"C:\Program Files\php-5.6.38-Win32-VC11-x64\php.exe"
启动 php.exe-l
php.exe 选项以使用其 lint 服务而不是执行$(FULL_CURRENT_PATH)
Notepad++ 特定的,它提供了当前打开文档的完整路径