Add composer package using path for development

Testing a Local Laravel Package with Composer Path Repositories

When developing a custom Laravel package, you might want to test it inside another Laravel project without publishing it to Packagist. Composer allows this with the path reposit…


This content originally appeared on DEV Community and was authored by Orfeo

Testing a Local Laravel Package with Composer Path Repositories

When developing a custom Laravel package, you might want to test it inside another Laravel project without publishing it to Packagist. Composer allows this with the path repository type, which creates a symlink to your package instead of copying it.

This way, any changes you make to the package’s files are instantly available in your testing project.

1. Add the Local Package Repository

In your Laravel project (the consumer project), tell Composer where your local package is located.

Run:

composer config repositories.local '{"type": "path", "url": "/absolute/path/to/my-dev-package"}' --file composer.json
  • Replace /absolute/path/to/my-dev-package with the full path to your package’s root folder.
  • This adds a repositories entry to your composer.json for the given path.

2. Require the Package

Install your package into the consumer project:

composer require my/dev-package
  • Use the same name defined in your package’s composer.json under "name": "my/dev-package".
  • Composer will create a symlink so changes in your package source are reflected immediately.

3. Work on the Package in Real Time

Since this is a symlink, you can:

  • Edit files in /absolute/path/to/my-dev-package
  • Refresh or run your Laravel project
  • See changes instantly without reinstalling the package

4. Optional: Use “version” for Better Control

If your package composer.json contains a "version" key (e.g., "version": "1.0.0") or uses a dev-branch version, Composer can handle updates more gracefully.

Example for a development branch:

"version": "dev-main"

Then require:

composer require my/dev-package:dev-main

5. When Ready to Publish

Once your package is stable, you can:

  • Remove the path repository from composer.json
  • Require it from Packagist or your private VCS repository


This content originally appeared on DEV Community and was authored by Orfeo


Print Share Comment Cite Upload Translate Updates
APA

Orfeo | Sciencx (2025-10-11T16:34:09+00:00) Add composer package using path for development. Retrieved from https://www.scien.cx/2025/10/11/add-composer-package-using-path-for-development/

MLA
" » Add composer package using path for development." Orfeo | Sciencx - Saturday October 11, 2025, https://www.scien.cx/2025/10/11/add-composer-package-using-path-for-development/
HARVARD
Orfeo | Sciencx Saturday October 11, 2025 » Add composer package using path for development., viewed ,<https://www.scien.cx/2025/10/11/add-composer-package-using-path-for-development/>
VANCOUVER
Orfeo | Sciencx - » Add composer package using path for development. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/10/11/add-composer-package-using-path-for-development/
CHICAGO
" » Add composer package using path for development." Orfeo | Sciencx - Accessed . https://www.scien.cx/2025/10/11/add-composer-package-using-path-for-development/
IEEE
" » Add composer package using path for development." Orfeo | Sciencx [Online]. Available: https://www.scien.cx/2025/10/11/add-composer-package-using-path-for-development/. [Accessed: ]
rf:citation
» Add composer package using path for development | Orfeo | Sciencx | https://www.scien.cx/2025/10/11/add-composer-package-using-path-for-development/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.