Adding Composer Dependencies Into Laravel 5

2015-02-19 Laravel

Adding Composer dependencies into Laravel 5 is very easy but you have to remember about few things. To add third party packages into your Laravel, locate file called composer.json (root of your project) and paste the name of the package in require / require-dev section. In my case I had to add “illuminate/html”: “~5.0” package to use link_to_route method in my view.

Look for require-dev and at the end of this array add

"illuminate/html": "~5.0"

Now all you have to do is to update the Composer. Run

sudo composer update

so it will update your dependencies to the latest version according to composer.json.

If your Composer version is too old, you will get an exception quite similar to

Could not load package dragonrun1/phpspec in [UnexpectedValueException] Could not parse version constraint ^1.0.1: Invalid version string "^1.0.1"

Could not parse version constraint ^1.0.1: Invalid version string "^1.0.1"

That means you have to update Composer itself. Run

sudo composer self-update


sudo composer selfupdate

(both commands do exactly the same) and then

sudo composer update

You’re done.


Do NOT follow this link or you will be banned from the site!