I accidentally didn't remove the VCS require from my composer.json before testing with the "autoload" key. It's now my understanding (based on what just happened) that the autoload section of composer.json is processed at runtime. If this is correct I may have solved my problem. (false, but a InvalidArgumentException exception will be thrown by PHP if the trailing "\\\\" is missing from the namespace name, hence the confusion)
The PSR-4 autoloader is independant of the git repository and does not require me to commit changes before testing, so this solution is sufficient for my purposes.
I'm going to leave this question open for now in case somebody has an answer to my question in broader terms. (ie answer to the question as stated in the title)
I'm attempting to build something primarily for use on a specific project, but as I think it will be useful to others I've decided to make it a Composer package.
What I want to do is develop the composer package on a git repository, and do manual testing inside my own project where I'm using the package.
The solutions I've found are as follows, but neither are sufficient:
The big issue with this method is that for every small change I make I need to commit changes before being able to test them. I'll wind up with tons of commits for my own silly syntax or api mistakes because I didn't test - not cool.
Unfortunately this method has the same issue. I need to commit my changes if I want to perform manual testing, otherwise the following message appears when running "composer update": (see "Update / My Solution" header)
[RuntimeException]
Source directory /srv/http/my-project/vendor/my-package
has unpushed changes on the current branch:
M composer.json
A src/EditorApplication.php
There must be a way to do something so necessary in Composer without resorting to this. How do you test uncommited changes to a composer package without doing the implementation inside the package itself? Is it even possible?
What I want to do is develop the composer package on a git repository, and do manual testing inside my own project where I'm using the package.
How do you test uncommited changes to a composer package without doing the implementation inside the package itself? Is it even possible?
You can define the local child project's repository as a path
repository in your root project's composer.json
. The path
allows you to depend on a local directory.
Referencing: https://getcomposer.org/doc/05-repositories.md#path
When the local development phase for the child project finishes, you can publish it and tag it instantly to have a first version out. You are skipping the dev-master
phase by having a version listed on Packagist, which can then be included by the/any parent project.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.