o0elvis0o's avatar

How/where do I run 'composer update'?

I bought a functional project built in Laravel, set it up on my server, and it is working perfectly. There are some features I would like to add but the author isn't interested in doing custom work however he is very supportive when it comes to questions regarding his original work.

So, I searched through the Laravel packages and have found things that sound cool and I would like to try to add them to my existing project. For example: messenger http://packalyst.com/packages/package/cmgmyr/messenger

I see my composer,json file where I can add the lines of code given in the installation instructions but the next step is to run 'composer update'.

Where/how do I do this?

Thanks

0 likes
8 replies
mstnorris's avatar

@o0elvis0o Do it from your project root, where the composer.json file is located.

You can manually add dependencies to your composer.json file or, from within your project root, on the command line:

composer require package-vendor/package-name
1 like
o0elvis0o's avatar

Ah! I use Putty. I have seen that in my search for help but didn't understand how to use it.

I have logged into my cpanel and used cd to get to the project root where the composer.json file is found.

The instructions have "cmgmyr/messenger": "~2.0". How do I specify the 2.0 ? Would it be:

composer require cmgmyr/messenger 2.0 ?

1 like
o0elvis0o's avatar

I realized I didn't have composer installed. I thought it came with Laravel. I installed composer using the command line and got the message saying composer successfully installed to my root folder. It said also said Use it: php composer.phar.

I cd back to the root directory and tried running composer require cmgmyr/messenger but got the same error message as before stating -bash composer: command not found.

Did I miss a step?

o0elvis0o's avatar

I ran curl -sS https://getcomposer.org/installer | php -- --check and it came back saying all settings correct for composer. But no commands are working.

I ran php composer.phar install and it came back with: Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Generating autoload files

php artisan clear-complied php artisan optimized Generating optimized class loader Compiling common classes

Commands still not working. Apparently I am overlooking something...

o0elvis0o's avatar

--Resolved-- (rambling to myself)

I had tried php composer.phar earlier and it spit out a list of available commands. Nothing else seemed to work except when I ran php composer.phar install. I noticed a pattern.

So I tried php composer.phar require cmgmyr/messenger and it worked!

I have no idea what difference the 'php composer.phar' makes but it makes a world of difference with my setup. Thanks for pointing me in the right direction @mstnorris

mstnorris's avatar

@o0elvis0o

tl;dr

Run the following command from where your composer.phar file is located. This will mean you can just run composer from now on.

mv composer.phar /usr/local/bin/composer

Explanation

You need to move the composer.phar into your /usr/local/bin directory. (This is installing it globally). See the Composer documentation. A .phar file is a PHP Archive, and is an executable file, just like any other. When I say you need to move it, you don't actually need to do anything, but by doing so it will save you typing out the full php composer.phar all the time. Also, by moving it to that directory it is available "system-wide".

I hope this clears things up for you. (Also I see you have a subscription, Check out the lesson Meet Composer from the Laravel 5 Fundamentals series.

1 like

Please or to participate in this conversation.