php-task/task-bundle
Symfony integration for php-task. Provides handler discovery, flexible task execution, management and debug commands, database persistence for tasks and executions, plus run statistics for every task execution.
composer require php-task/task-bundle. Version 4.1.0 only widens the Symfony constraint to allow ^8.0 alongside the existing 4.x-supported versions — no install steps changed.PhpTask\TaskBundle\PhpTaskBundle (or TaskBundle, check the class name in vendor/php-task/task-bundle/src) in config/bundles.php. Note: this is a Symfony bundle, not a Laravel package — there is no service provider or facade.php bin/console list and look for the bundle's task command (naming varies by major version — grep vendor/php-task/task-bundle/src/Command if it isn't obvious). That command is the fastest way to confirm the bundle is wired up and discoverable.composer show php-task/task-bundle and your PHP version before upgrading: Symfony 8 requires PHP 8.4+, so 4.1.0 is a no-op on older runtimes and only becomes relevant when you move the framework forward.Task as a container-managed service. Implement the task interface (PhpTask\Task\TaskInterface, or extend the provided base Task), inject your repositories/clients normally, and rely on autoconfiguration to tag it. If you disable autoconfigure, add the tag explicitly:
App\Task\ReindexProductsTask:
tags: ['php_task.task'] # confirm the exact tag in the bundle's DI extension
Compose, don't inherit. Prefer TaskFactory to build tasks from callables for one-offs, and CollectionRunner when you need to run a set of tasks in sequence with shared progress reporting. This keeps task classes small and avoids deep inheritance trees.
Invoke from a console command. The common production pattern is your own command that pulls the runner from the container, attaches tasks, and runs them — giving you a place to add --dry-run, tenant filters, and locking:
protected function execute(InputInterface $input, OutputInterface $output): int
{
$collection = $this->collectionRunner;
$collection->addTask($this->taskFactory->create($this->reindexTask));
$collection->run();
return self::SUCCESS;
}
Progress and output. Wire the console-output progress adapter into the runner so long jobs report incrementally rather than appearing hung. Keep task-level logging inside the task, and let the runner own the bar.
Laravel-side integration. Without a Laravel provider, the practical pattern is to use the underlying php-task/task library directly and wrap the runner in an Artisan command or a queued job; bind the runner as a singleton in a service provider so tasks compose the same way they do in Symfony.
php-task/task itself, not this bundle — plan for a thin adapter, not a drop-in.^6|^7 to include ^8. Upgrading is safe, but composer update may also pull the Symfony 8 line on PHP 8.4 projects — pin framework packages if you are not ready.sleep, large DB loops) stalls the loop and freezes progress output. Batch your blocking work or push it into child processes.__construct gets executed on container resolution, not on run.CollectionRunner should be independent; carrying state between them turns retries into a debugging nightmare.-vvv, confirm the task appears in the bundle's list command before debugging execution, and check debug:container --tag=<task-tag> to verify the service is tagged. In dev, the Symfony profiler shows the runner timeline.debug:container remains the source of truth.How can I help you explore Laravel packages today?