2

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 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, that was indeed the problem. It's very strange that anything works this way in Windows, but I guess I have to remember that this is an app originally meant for *nix :) In any case, is there some kind of global config where I can set its default directory? Or does it only work in the working directory?
You're welcome! As for the default location of the command prompt (that is what you meant, right?), I just had a quick google and it looks like you can set a default location, check here: sevenforums.com/customization/…. I am using windows 7 too but use use git bash which you may want to check that out if your more used to unix style commands. You can install here: git-scm.com/downloads
I was actually wondering about composer itself--is there a way to make it ignore the working directly and install to a specific default directory by default (unless specified otherwise)?
I'm not that experienced with composer tbh so perhaps I'm not the best person to answer and maybe that's why I'm not entirely sure why you'd want to do that, unless you're hoping to install packages globally? If you did want to do a global install try checking out composer global require, but I've never used it before so you may want to search around the web first and check the composer documentation for help. These links may help you out: akrabat.com/global-installation-of-php-tools-with-composer coderwall.com/p/ma_cuq/using-composer-to-manage-global-packages

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.