不久前,我使用php-cs-fixer成功地配置了Atom来美化我的PHP,但现在我需要在另一台Mac上经历同样的过程,并且记不清我是如何做到的。
作为一名前端开发人员,我不是PHP专家,但我知道Atom插件只是使用php-cs-fixer进行实际修复的中间人,默认情况下,它无法访问它。安装修复程序后,我必须将其位置添加到我的PATH
变量中。令人困惑的部分是,我没有通过Atom (选中~/.atom/packages)或Homebrew (通过brew list
确认)安装修复程序,但是,该文件位于/usr/local/bin中。如果我移动它,Atom会返回原始错误,所以它肯定使用了这个文件:
See https://github.com/FriendsOfPHP/PHP-CS-Fixer for program installation instructions.
Your program is properly installed if running 'which php-cs-fixer' in your Terminal returns an absolute path to the executable. If this does not work then you have not installed the program correctly and so Atom Beautify will not find the program. Atom Beautify requires that the program be found in your PATH environment variable.
Note that this is not an Atom Beautify issue if beautification does not work and the above command also does not work: this is expected behaviour, since you have not properly installed your program. Please properly setup the program and search through existing Atom Beautify issues before creating a new issue. See https://github.com/Glavin001/atom-beautify/search?q=php-cs-fixer&type=Issues for related Issues and https://github.com/Glavin001/atom-beautify/tree/master/docs for documentation. If you are still unable to resolve this issue on your own then please create a new issue and ask for help.
Hide Stack Trace
Error: Could not find 'php-cs-fixer'. The program may not be installed.
at PHPCSFixer.module.exports.Beautifier.commandNotFoundError (/Users/ourcore/.atom/packages/atom-beautify/src/beautifiers/beautifier.coffee:204:14)
at /Users/ourcore/.atom/packages/atom-beautify/src/beautifiers/beautifier.coffee:304:22
at tryCatcher (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:510:31)
at Promise._settlePromise (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:567:18)
at Promise._settlePromise0 (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:612:10)
at Promise._settlePromises (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:687:18)
at Async._drainQueue (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:138:16)
at Async._drainQueues (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:148:10)
at Async.drainQueues (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:17:14)
at process._tickCallback (internal/process/next_tick.js:103:7)
which php-cs-fixer
返回/usr/local/bin/php-cs-fixer
,我的PATH
变量当前包含/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ourcore/.atom/packages/php-cs-fixer
。
我想我的问题是,如果PATH
变量似乎指向不同位置的修复器,那么修复器是如何工作的,它是如何到达现在的位置的?我的本地中的位置重要吗,或者Atom插件知道要在/usr/ PATH
/bin中查找吗?我只是想在重复之前完全理解整个过程。
编辑:在进一步的测试中,我从我的PATH
中删除了Atom目录,它不会影响插件,所以我将文件复制到相同的目录中,然后在第二个Mac上运行,没有问题,不需要编辑PATH
。修复程序文件是否有人通知了操作系统?
发布于 2017-01-10 04:53:08
首先测试“哪个php-cs-fixer”或"where php-cs-fixer“(取决于你运行的是什么操作系统),如果终端没有返回任何东西,那么安装确实有问题,最好的办法是手动安装它。
访问https://github.com/FriendsOfPHP/PHP-CS-Fixer并从那里下载,然后按照安装步骤进行操作,之后一切都会很好
https://stackoverflow.com/questions/39864825
复制相似问题