Upgrading To 3.x from 2.x
High Impact Changes
- Change the location of the configuration file
- Replacing named classes with anonymous ones
- Changing the namespace of the parent class
- Changing variable names from
snake_case
tocamelCase
and added typing - Added recursive search for actions in a folder
- PHP 7.3 and 7.4 was dropped
- Laravel 6.0 was dropped
- Dragon Code: Contracts (
dragon-code/contracts
) was dropped
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 adown
method - Replace named classes with anonymous ones
- Create a configuration file according to the data saved in your project
- Changes properties from
snake_case
tocamelCase
Updating Dependencies
PHP 8.0.2 Required
Deploy Actions for Laravel 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
Configuration
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 Name | New Name |
---|---|
protected $once | protected bool $once |
protected $transactions | protected bool $transactions |
protected $transaction_attempts | protected int $transactionAttempts |
protected $environment | protected string|array|null $environment |
protected $except_environment | protected string|array|null $exceptEnvironment |
protected $before | protected bool $before |
Added recursive search for actions in a folder
Before:
2022_10_13_013321_test1
2022_10_13_013326_test2
bar/2022_10_13_013323_test3 # will not be called
After:
2022_10_13_013321_test1
2022_10_13_013326_test2
bar/2022_10_13_013323_test3 # will be called