Execution Status
You can also override the success
and failed
methods, which are called on success or failure processing.
Success
use DragonCode\LaravelDeployOperations\Operation;
use Illuminate\Support\Facade\Log;
return new class extends Operation {
public function up(): void
{
// some
}
public function down(): void
{
// some
}
public function success(): void
{
Log::info('success');
}
public function failed(): void
{
Log::info('failed');
}
};
Call the php artisan operations
command.
The log file will contain one success
record.
Failed
use DragonCode\LaravelDeployOperations\Operation;
use Illuminate\Support\Facade\Log;
return new class extends Operation {
public function up(): void
{
throw new Exeption();
}
public function down(): void
{
throw new Exeption();
}
public function success(): void
{
Log::info('success');
}
public function failed(): void
{
Log::info('failed');
}
};
Call the php artisan operations
command.
The log file will contain one failed
record.
Invokable
The methods will work in the same way in conjunction with the __invoke
magic method. The only difference is that in this case the down method will not be executed.
use DragonCode\LaravelDeployOperations\Operation;
use Illuminate\Support\Facade\Log;
return new class extends Operation {
public function __invoke(): void
{
// some
}
public function success(): void
{
Log::info('success');
}
public function failed(): void
{
Log::info('failed');
}
};
02 April 2025