Test your Laravel packagešŸ“¦ locally in your Laravel project

RadicalLoop
1 min readDec 6, 2017

Recently, while we were developing a new Laravel package, we wanted to check and ensure that everything works as expected in an ā€œactualā€ Laravel project.

While developing the package, we need a quick way to check functionality.

To do so, follow below steps:
1) Add your package in Laravel project: Letā€™s name it ā€œmypackageā€, add it to root directory of your project.

2) Add package ā€œrepositoriesā€ block in your composer.json. For general information on how to declare repositories, please refer to the composer documentation.

composer.json

{
....
"repositories": {
"dev-package": {
"type": "path",
"url": "mypackage", // Path to your package folder
"options": {
"symlink": true
}
}
}
....}

By setting the "type": "path" composer knows that you would like to reference a local repository and the url defines the package location.

symlink option and composer will create a symlink to the package folder in vendor directory.

3) The last step is to issue a composer require command to include the package in your Laravel project.

composer require radicalloop/mypackage @dev

After executing this command the package folder is symlinked into the applicationā€™s vendor folder and every change to your package will be immediately available in your application.

Thatā€™s it! Now you should be able to use/test your package in your Laravel project. Big thanks to composer. šŸ˜„

Any questions or suggestions? please comment!

Follow RadicalLoop on Twitter, Facebook. šŸš€

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Responses (1)

Write a response