This is a simple (framework agnostic) library for running tasks once (and only once) at deployment time. Out of the box, it's designed to work with the Knp Gaufrette library so that you can persist the tasks that have run anywhere you want (ideally, a database if your project has access to it)
composer req c0ntax/deployment-tasks
Err, that's it
Configuration is simple. All you need to do is inject two configured Gaufrette Filesystems into the TaskService. They are:
use C0ntax\DeploymentTasks\Service\TaskService;
use Gaufrette\Filesystem;
use C0ntax\DeploymentTasks\Gaufrette\Adapter\Local;
use Gaufrette\Adapter\DoctrineDbal;
$taskFilesystem = new Filesystem(new Local('/path/to/tasks'));
$memoryFilesystem = new Filesystem(new DoctrineDbal(...));
$taskService = new TaskService($taskFilesystem, $memoryFilesystem);
You also need to make sure that you've set up the task directories. For example:
/path
/to
/tasks
/Pre
/task1232198312.sh
/task3210948323.sh
/Post
/tasks0298340932.sh
Once it's configured, then you just have to pass the TaskService as defined above into the RunnerService
use C0ntax\DeploymentTasks\Contracts\TaskServiceInterface;
use C0ntax\DeploymentTasks\Service\RunnerService;
$runnerService = new RunnerService($taskService);
// To run pre deployment tasks (i.e. the codebase has been build and staged, but is not yet live)
$runnerService->run(TaskServiceInterface::TASK_TYPE_PRE);
// To run post deployment tasks (i.e. the codebase is now live and taking requests)
$runnerService->run(TaskServiceInterface::TASK_TYPE_POST);
How can I help you explore Laravel packages today?