问题
I am new to Laravel and Composer, and am following some guides including LaraCasts.com . One of the things that need to be done is use Composer to require packages to use in the Laravel project. However, this doesn't work for me.
I installed Laravel using the composer create-project
method (http://laravel.com/docs/5.0), and so far everything was fine. However, any package I "require" now actually goes into the C:\Users\user\vendor folder, and the composer.json file is in C:\Users\user.
I understand that Composer is supposed to separate between projects as opposed to being global like PEAR. So how do I specify that I'm working on a specific project and require everything into that project? Also, what is the actual path where I'm supposed to put packages in Laravel, in case I want to do it manually?
I am using Windows 7 and Xampp.
回答1:
When you run composer require {pacakage}
, make sure you use the cd
command (Change Directory - I think) into the project you want to install the package for. So if you're in Xampp it could be something like cd C:\xampp\htdocs\my-laravel-project\
or whatever the path to your project is, then run your composer require {pacakage}
.
I believe it's installing it in C:\Users\user\vendor
as when you open your terminal/command prompt the default location is C:\Users\{username}\
.
Please make sure you ran the composer create-project
in your web root, for Xampp I think it's C:\xampp\htdocs\
but it could be different depending on how you set up Xampp when you installed it.
来源:https://stackoverflow.com/questions/29509367/how-to-require-package-into-laravel-project-with-composer