osdd:remove
osdd:remove removes a layer from the project: its root composer.json entries, its phpunit.xml entries and its directory. It refuses a layer that another layer still requires.
php artisan osdd:remove functional/legacy
Arguments and options
| Argument / Option | Description |
|---|---|
name | The layer to remove: full name, or package name when it is unique. |
--keep-files | Keep the layer directory. |
--force | Remove the layer without asking. Required without a terminal. |
--composer-update / --no-composer-update | Run or skip composer update vendor/package without asking. |
php artisan osdd:remove functional/legacy # prints the changes, then asks
php artisan osdd:remove legacy --force --composer-update # scripts: no question, then composer update
php artisan osdd:remove functional/legacy --keep-files --force
How it works
1. Refusal
When another layer lists the layer in its require or require-dev, the command exits with 1 and changes nothing:
Layer [functional/legacy] is required by functional/orders: remove it from their require or require-dev first.
Remove the requirement, and the code that uses the layer, first. osdd:check finds that code.
2. Summary
The command prints every change before it makes it:
INFO Removing layer [functional/legacy]:
composer.json: require functional/legacy ................................ REMOVE
composer.json: path repository ./functional/* (still covers other packages) KEEP
phpunit.xml: test suite functional/legacy ............................... REMOVE
phpunit.xml: coverage source functional/legacy/src ...................... REMOVE
Directory functional/legacy ............................................. DELETE
Database tables of its 1 migration ........................................ KEEP
A path repository is removed only when it covers the layer and no other package directory.
3. Confirmation
It asks Remove the layer [functional/legacy]? (default: no). Answering no exits with 1 and prints Nothing was removed.. Without a terminal or with -n, it removes nothing and exits with 1 unless you pass --force:
Nothing was removed. Pass --force to remove [functional/legacy] without interaction.
4. Removal
It removes the require or require-dev entry and the obsolete path repositories from the root composer.json, removes the test suite and the coverage source written by osdd:phpunit, deletes the directory unless --keep-files, and refreshes an existing layer cache.
When the layer has migrations, it warns that their tables stay:
The tables created by the migrations of [functional/legacy] stay in the database: drop them with a migration of another layer if they are no longer needed.
5. Composer
In a terminal, it asks to run composer update functional/legacy (default: yes). Otherwise it prints Run composer update functional/legacy now to uninstall the layer.. A failed update exits with 1.
composer update right away. Until Composer runs, Laravel's package manifest still lists the deleted layer's provider, and every artisan command fails with a class-not-found error. composer update itself works.After removing a layer
- When config, routes or events are cached, run
php artisan optimizeagain: those caches still name the layer's classes. - With
--keep-files, the directory stays in its layer folder, so it is still discovered:osdd:listshows it as not required. Move it out ofosdd.layers.pathsor delete it later.
See Remove a layer for the whole procedure, from the layers that still use it to its tables.