Local Laravel Package Testing with Composer Path Repositories
The article details an efficient method for testing a local Laravel package within a separate Laravel consumer project without the need to publish it to Packagist. This is achieved by leveraging Composer’s `path` repository type, which fundamentally creates a symlink to the local package’s directory rather than copying its files. The primary benefit of this approach is enabling real-time development: any modifications made to the package’s source files are instantly reflected and available in the testing project, eliminating the need for constant reinstallation or cache clearing. This significantly streamlines the development workflow for custom Laravel packages.
The process involves a few straightforward steps. First, the consumer Laravel project must be configured to recognize the local package’s location. This is done by executing a `composer config` command, specifying the repository type as “path” and providing the absolute URL to the package’s root folder. This action adds a `repositories` entry to the consumer project’s `composer.json` file. Next, the local package is required into the consumer project using the standard `composer require` command, ensuring the package name matches what is defined in its own `composer.json`. Composer then establishes the symlink, allowing immediate access to package changes.
For enhanced control, especially during active development, the article suggests incorporating a “version” key, such as “dev-main,” into the package’s `composer.json`. This allows the package to be required with a specific development branch version, making Composer handle updates more gracefully. While the article doesn’t explicitly mention risks, it implicitly highlights the importance of transitioning away from the `path` repository once development is complete. When the package is stable and ready for production, developers must remove the path repository entry from their `composer.json` and then require the package from its official source, like Packagist or a private VCS repository, ensuring proper dependency management for published versions. This method is invaluable for iterative package development and testing.
(Source: https://dev.to/orfeo/add-composer-package-using-path-for-development-795)


