我开始考虑在我的php项目中使用composer 。 我有MAMP Pro,并希望继续使用它为我的开发主机。 问题是我无法让作曲家在我的/Users/***/文件夹(它运行得非常好)的任何地方运行。 如何让它在我的MAMP服务器的根目录中运行? 我已经搞乱了.bash_profile文件,添加了以下行:
alias composer='php composer.phar' export PATH=/Applications/MAMP/bin/php/php7.0.10/bin:$PATH这不起作用(别名也不起作用)。 vendor文件仍显示在/Users/***/文件夹中。
任何帮助将不胜感激!
I started looking into using composer for my php project. i have MAMP Pro and would like to continue to use that for my development hosting. The problem is that I can't get composer to run anywhere accept in my /Users/***/ folder (where it runs really well). How would I get it to run in the root of my MAMP Server? I have messed with the .bash_profile file adding the following lines:
alias composer='php composer.phar' export PATH=/Applications/MAMP/bin/php/php7.0.10/bin:$PATHThat does not work (and neither does the alias). The vendor file still shows up in the /Users/***/ folder.
Any help would be greatly appreciated!
最满意答案
您可以进行全局安装:
由于Composer使用当前工作目录,因此可以以系统范围的方式安装它。
1.转到路径中的目录,如cd / usr / local / bin
2.Get Composer curl -sS https://getcomposer.org/installer | PHP
3.使phar可执行文件chmod a + x composer.phar
4.转换到项目目录cd / path / to / my / project
5.像往常一样使用Composer.phar安装使用Composer
更新:有时您不能或不想在/ usr / local / bin下载(有些人遇到过用户权限问题或限制访问权限),在这种情况下你可以尝试这个
Open terminal curl -sS http://getcomposer.org/installer | php -- --filename=composer chmod a+x composer sudo mv composer /usr/local/bin/composerOk after looking at it a little bit more here's what I figured out using @Lokesh Gamot's answer and the composer site. Again, this is geared to use with MAMP.
Find the path of your development server. I would suggest putting var_dump(getcwd()); at the top of your index.php file to get the path to show up on your index page. For me, it was /Applications/MAMP/htdocs/.../web-root Because I wanted composer in my server root, I inputted cd "/Applications/MAMP/htdocs/" into the terminal. I then downloaded the file using curl -sS https://getcomposer.org/installer | php -- --filename=composer. This installs Composer into "/Applications/MAMP/htdocs/" as a file named composer.When I begin a new project, I have to move the composer file into the project root using mv composer "/Applications/MAMP/htdocs/*Destination Root*" and then navigate the terminal to that same root by using: cd "/Applications/MAMP/htdocs/*Destination Root*". What I was missing was needing to move the composer file around to each root when I needed it.
After that, I can use composer using php composer. Again, thanks!
更多推荐
发布评论