Sign in

How to test a Laravel package locally

Howdy!

Lately I’ve been working on submitting a PR to a package, Laravel package to be precise.

I forked & cloned the project to my local machine. I made my adjustments, and then I want to test it, because it has a visual interface.

But I had a problem linking it an existing Laravel app to see those adjustments. So reading Composer docs, I found “Repositories”, and you can use it to link a local composer package, How ?

First of all, after cloning or creating your own package, you can link it in your main application by editing composer.json, adding this :

"repositories": [
{
"type": "path",
"url": "../../awesome/package"

}
]

Note: the url must be the full path to the package.

After that, add the package to the require section

..."require": {"awesome/package": "@dev"}
...

And finally

$ composer update

Composer now will link the package to the main app, and any change you make in the package will be reflected immediately into your app.

Thank you for reading.