Upgrading To 3.x from 2.x

High Impact Changes

Medium Impact Changes

The easiest way to upgrade

Note If you used inheritance of actions from other actions, then you will need to process these files manually.

For your convenience, we have created an upgrade console command:

composer require dragon-code/laravel-migration-actions:^3.0
php artisan migrate:actions:upgrade
php artisan migrate

It will do the following:

  • Change the namespace of the abstract class
  • Add a strict type declaration
  • Replace the up method with __invoke if the class does not have a down method
  • Replace named classes with anonymous ones
  • Create a configuration file according to the data saved in your project
  • Changes properties from snake_case to camelCase

Updating Dependencies

PHP 8.0.2 Required

Laravel Actions now requires PHP 8.0.2 or greater.

Composer Dependencies

You should update the following dependency in your application's composer.json file:

  • dragon-code/laravel-migration-actions to ^3.0


Publish the config file and migrate the settings from the config/database.php file to config/actions.php.

php artisan vendor:publish --provider="DragonCode\LaravelActions\ServiceProvider"

Actions Location

Move the action files to the actions folder in the project root, or update the actions.path option in the configuration file.

Parent Namespace

Replace DragonCode\LaravelActions\Support\Actionable with DragonCode\LaravelActions\Action.

Anonymous Classes

Replace named calls to your application's classes with anonymous ones.

For example:

// before
use DragonCode\LaravelActions\Support\Actionable;

class Some extends Actionable {}

// after
use DragonCode\LaravelActions\Action;

return new class () extends Action {};

Invokable Method

If your class does not contain a down method, then you can replace the up method with __invoke.

Changed Action Repository

Just call the php artisan migrate command to make changes to the action repository table.

Changed Properties

Make sure all overridden properties are typed:

Old NameNew Name
protected $onceprotected bool $once
protected $transactionsprotected bool $transactions
protected $transaction_attemptsprotected int $transactionAttempts
protected $environmentprotected string|array|null $environment
protected $except_environmentprotected string|array|null $exceptEnvironment
protected $beforeprotected bool $before

Added recursive search for actions in a folder


bar/2022_10_13_013323_test3 # will not be called


bar/2022_10_13_013323_test3 # will be called