Add detailed notes about events in upgrade guide, add COMPOSER_DEBUG_EVENTS env var for debugging events
parent
cb1c35ab52
commit
3c25d180e6
|
@ -30,7 +30,7 @@
|
|||
- packages now contain an `"installed-path"` key which lists where they were installed
|
||||
- there is a top level `"dev"` key which stores whether dev requirements were installed or not
|
||||
- Removed `OperationInterface::getReason` as the data was not accurate. There is no replacement available.
|
||||
- `PreFileDownloadEvent` now receives an `HttpDownloader` instance instead of `RemoteFilesystem`, and that instance cannot be overridden by listeners anymore
|
||||
- `PreFileDownloadEvent` now receives an `HttpDownloader` instance instead of `RemoteFilesystem`, and that instance cannot be overridden by listeners anymore, you can however call setProcessedUrl or setCustomCacheKey.
|
||||
- `VersionSelector::findBestCandidate`'s third argument (phpVersion) was removed in favor of passing in a complete PlatformRepository instance into the constructor
|
||||
- `InitCommand::determineRequirements`'s fourth argument (phpVersion) should now receive a complete PlatformRepository instance or null if platform requirements are to be ignored
|
||||
- `IOInterface` now extends PSR-3's `LoggerInterface`, and has new `writeRaw` + `writeErrorRaw` methods
|
||||
|
@ -46,8 +46,32 @@
|
|||
- `prepare` (do user prompts or any checks which need to happen to make sure that install/update/remove will most likely succeed), `install` (should do the non-network part that `download` used to do) and `cleanup` (cleaning up anything that may be left over) were added as new steps in the package install flow
|
||||
- All packages get first downloaded, then all together prepared, then all together installed/updated/uninstalled, then finally cleanup is called for all. Therefore for error recovery it is important to avoid failing during install/update/uninstall as much as possible, and risky things or user prompts should happen in the prepare step rather. In case of failure, cleanup() will be called so that changes can be undone as much as possible.
|
||||
- If you used `RemoteFilesystem` you probably should use `HttpDownloader` instead now
|
||||
- `PRE_DEPENDENCIES_SOLVING` and `POST_DEPENDENCIES_SOLVING` events have been removed, use the new `PRE_OPERATIONS_EXEC` or other existing events instead or talk to us if you think you really need this
|
||||
- `PRE_DEPENDENCIES_SOLVING` and `POST_DEPENDENCIES_SOLVING` events have been removed, use the new `PRE_OPERATIONS_EXEC`, `PRE_POOL_CREATE` or other existing events instead or talk to us if you think you really need this. See below for more details.
|
||||
- The bundled composer/semver is now the 3.x range, see release notes for [2.0](https://github.com/composer/semver/releases/tag/2.0.0) and [3.0](https://github.com/composer/semver/releases/tag/3.0.0) for the minor breaking changes there
|
||||
- Run Composer with COMPOSER_DEBUG_EVENTS=1 set in the environment to show which events happen which might help you.
|
||||
|
||||
### Detailed differences in event flow during dependency resolution, composer updates and installs
|
||||
|
||||
#### Composer v1
|
||||
|
||||
- Composer resolves dependencies (dispatching PRE/POST_DEPENDENCIES_SOLVING)
|
||||
- It then iterates over all packages one by one (dispatching PRE_PACKAGE_INSTALL/UPDATE/UNINSTALL, then PRE_FILE_DOWNLOAD if needed, then POST_PACKAGE_*)
|
||||
- And finally writes the lock file at the end
|
||||
|
||||
#### Composer v2
|
||||
|
||||
The update and install process have been split up.
|
||||
|
||||
Update does:
|
||||
|
||||
- Composer resolves dependencies (dispatching PRE_POOL_CREATE)
|
||||
- It then writes the lock file and that's the end of the update
|
||||
|
||||
Install then does:
|
||||
|
||||
- Dispatches PRE_OPERATIONS_EXEC with the full list of operations to be executed
|
||||
- Downloads all the packages not in cache yet in parallel (dispatching PRE_FILE_DOWNLOAD for those not in cache yet)
|
||||
- It then iterates over all packages and executes updates/installs/uninstalls in parallel (dispatching PRE_PACKAGE_INSTALL/UPDATE/UNINSTALL then POST_PACKAGE_* but one package started last may finish installing before another is done for example).
|
||||
|
||||
## For Composer repository implementors
|
||||
|
||||
|
|
|
@ -1039,4 +1039,9 @@ to run Composer on a plane or a starship with poor connectivity.
|
|||
If set to `prime`, GitHub VCS repositories will prime the cache, so it can then be used
|
||||
fully offline with `1`.
|
||||
|
||||
### COMPOSER_DEBUG_EVENTS
|
||||
|
||||
If set to `1`, outputs information about events being dispatched, which can be
|
||||
useful for plugin authors to identify what is firing when exactly.
|
||||
|
||||
← [Libraries](02-libraries.md) | [Schema](04-schema.md) →
|
||||
|
|
|
@ -94,6 +94,10 @@ and have it return an array. The array key must be the
|
|||
[event name](https://getcomposer.org/doc/articles/scripts.md#event-names)
|
||||
and the value is the name of the method in this class to be called.
|
||||
|
||||
> **Note:** If you don't know which event to listen to, you can run a Composer
|
||||
> command with the COMPOSER_DEBUG_EVENTS=1 environment variable set, which might
|
||||
> help you identify what event you are looking for.
|
||||
|
||||
```php
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
|
|
|
@ -144,6 +144,14 @@ class EventDispatcher
|
|||
*/
|
||||
protected function doDispatch(Event $event)
|
||||
{
|
||||
if (getenv('COMPOSER_DEBUG_EVENTS')) {
|
||||
$details = null;
|
||||
if ($event instanceof PackageEvent) {
|
||||
$details = (string) $event->getOperation();
|
||||
}
|
||||
$this->io->writeError('Dispatching <info>'.$event->getName().'</info>'.($details ? ' ('.$details.')' : '').' event');
|
||||
}
|
||||
|
||||
$listeners = $this->getListeners($event);
|
||||
|
||||
$this->pushEvent($event);
|
||||
|
|
Loading…
Reference in New Issue