# Upgrade from 3.0

> Move a Laravel OSDD 3.0 project to 3.1.

## Upgrading to 3.1 from 3.0

Check the points below after `composer update lomkit/laravel-osdd`.

### Discovered listeners run in a stable order

The listeners discovered in the layers now run by layer name, then class name, then method name (byte order), instead of the order the file system listed them in, which differed between machines. Listeners registered while the providers boot (`Event::listen()` in a `boot()`, `$listen`, `app/Listeners`) still run first.

If two discovered listeners of the same event only worked in one order, make that order explicit: one listener that calls the steps in order, a follow-up event, or both registered by hand, in order, in one provider's `boot()` (discovery skips a listener already registered there). See [Events](/guides/events#order).

With a cached event list, the new order applies from the next `php artisan event:cache` (or `optimize`), and the cached file is now the same on every machine.

### `osdd:list` health

A layer whose provider does not extend `Lomkit\Osdd\LayerServiceProvider`, such as a Horizon or Telescope provider, and a layer without a provider are now healthy: the Health row no longer reports "provider does not extend LayerServiceProvider", and the Providers row marks such a class "(not a LayerServiceProvider)".

In `osdd:list --json`, `health.provider_extends_layer_service_provider` keeps its name and its `true`, `false` or `null` value, but a layer without a provider now gives `null` instead of `false`. The flag is information, not a problem: a script that fails on `false` should stop checking it. See [`osdd:list`](/commands/osdd-list#providers).

### Generators write only into a `LayerServiceProvider`

The generators that wire the layer provider (`osdd:migration`, `osdd:seeder`, `osdd:config`, `osdd:view`, `osdd:component`, `osdd:command` and the `osdd:*-table` commands) wrote into the first provider of `extra.laravel.providers` found on disk, whatever its class, and a call that only `LayerServiceProvider` has then failed at boot. They now write into the first listed provider that extends `LayerServiceProvider`, else into `src/Providers/{Package}ServiceProvider.php` when it does. With no such provider they change no file and print the line to add. The provider of a layer that is not installed yet counts only when its class extends `Lomkit\Osdd\LayerServiceProvider` directly.

If a generator now prints the line instead of editing your provider, make that provider extend `Lomkit\Osdd\LayerServiceProvider`, or create one with `osdd:provider`. See [Generators that wire the provider](/commands/make-commands#generators-that-wire-the-provider).

### `osdd:provider` writes a `LayerServiceProvider`

`osdd:provider` now writes a class that extends `Lomkit\Osdd\LayerServiceProvider`, with empty `register()` and `boot()` methods, instead of Laravel's provider extending `Illuminate\Support\ServiceProvider`. It no longer reads a published `stubs/provider.stub`.

A provider that 3.0's `osdd:provider` wrote can be changed to extend `LayerServiceProvider`, which only adds protected helpers to `ServiceProvider`; the generators can then wire it:

```diff
-use Illuminate\Support\ServiceProvider;
+use Lomkit\Osdd\LayerServiceProvider;

-class OrderEventsServiceProvider extends ServiceProvider
+class OrderEventsServiceProvider extends LayerServiceProvider
```

### `osdd:phpunit` reads `phpunit.xml` as PHPUnit does

`osdd:phpunit` no longer adds a layer source directory that a `<source><include>` entry already covers: a glob (`functional/*/src`, `functional/**/src`), the same path written another way (`./functional/orders/src/`) or a parent folder, when that entry has no `prefix` and the `.php` suffix. The duplicates an earlier run added next to such entries can be removed: they are not added back.

`--prune` no longer removes glob entries, and removes a literal entry only when it resolves to no folder. If `--prune` removed glob entries from your `phpunit.xml`, add them back. See [`osdd:phpunit`](/commands/osdd-phpunit#entries-that-already-cover-a-layer).

### `osdd:phpunit` no longer writes the migrations exclusions

`osdd:phpunit` no longer adds `<bucket>/*/database/migrations` under `<source><exclude>` (`functional/*/database/migrations`, `technical/*/database/migrations`). It writes one test suite and one source include per layer, the layer's source directory (`src`), which holds no migrations: the exclusion removed no file. The exclusions already in your `phpunit.xml` are left as they are.

If every `<source><include>` entry is a layer `src`, you can delete those lines:

```diff [phpunit.xml]
<exclude>
-    <directory suffix=".php">functional/*/database/migrations</directory>
-    <directory suffix=".php">technical/*/database/migrations</directory>
 </exclude>
```

If you include a whole bucket (`<directory>functional</directory>`), keep them, or switch to `functional/*/src`.

The source includes it adds no longer carry `suffix=".php"`, which is PHPUnit's default. The entries already in the file are left as they are.

### `osdd:phpunit` keeps the formatting of `phpunit.xml`

The first run no longer reformats `phpunit.xml` (2-space indentation, the attributes of `<phpunit>` on one line): an added entry takes the indentation of its neighbours, a removed one leaves no blank line, and the rest of the file is unchanged. `osdd:remove` writes `phpunit.xml` the same way.

A file an earlier run reformatted keeps its current layout: restore yours from version control if you want it back.

### `osdd:phpunit` prints only its changes

`osdd:phpunit` no longer prints a `SKIPPED` line for each layer whose test suite is already present. It prints the entries it adds or removes, or `phpunit.xml is already up to date.` when nothing changes. The layers without a `tests/` directory are named with `-v` only.
