Composer Server不会将供应商文件加载到服务器根目录中(Composer Server won't load vendor file into server root)

编程入门 行业动态 更新时间:2024-10-25 04:21:46
Composer Server不会将供应商文件加载到服务器根目录中(Composer Server won't load vendor file into server root)

我开始考虑在我的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:$PATH

That 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/composer

Ok 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!

更多推荐

本文发布于:2023-07-28 18:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1308002.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:根目录   会将   加载   供应商   服务器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!