Skip to content

Custom tasks

Every task package registers its tasks in the core TaskProviderRegistry. You can do the same from your castor.php: the tasks are then exposed by every SyliusService, like the built-in ones.

use Castor\Attribute\AsTask;
use SyliusStarter\Core\Service\SyliusService;
use SyliusStarter\Core\Task\TaskProviderRegistry;
use function Castor\io;
TaskProviderRegistry::register('my_tasks', static fn (SyliusService $service): iterable => [
[
'task' => new AsTask('hello', 'sylius:my', 'Say hello'),
'function' => static fn () => io()->success(\sprintf('Hello from %s', $service->getName())),
],
]);

A package can also hook into castor docker:service:install sylius (extra questions and steps run once Sylius is installed) by registering a SyliusInstallerExtensionInterface in SyliusInstallerExtensions, as sylius-starter/themes does to ask which storefront theme to use.