Install the Bundle
composer require aymdev/fregata-bundle
Ensure your project meets the requirements: PHP 8.1+, Symfony 4.4/5.x.
Configure Database Entities Run Doctrine migrations to create the required tables:
php bin/console make:migration
php bin/console doctrine:migrations:migrate
Configure Messenger Transport
Edit config/packages/messenger.yaml to route FregataMessageInterface to your transport (e.g., async):
framework:
messenger:
transports:
async: '%env(MESSENGER_TRANSPORT_DSN)%'
routing:
'Fregata\FregataBundle\Messenger\FregataMessageInterface': async
Enable UI Routes
Create config/routes/fregata.yaml:
fregata:
resource: "@FregataBundle/Resources/config/routes.xml"
prefix: /fregata
First Migration Run Trigger a migration via CLI or UI:
php bin/console fregata:migration:execute
Or navigate to /fregata and click "New run".
Define Migrations
Use Fregata’s core framework to define migrations (e.g., BeforeTask, Migrator, AfterTask). Example:
use Fregata\Migration\Migration;
class MyMigration extends Migration
{
protected function configure(): void
{
$this->addMigrator(new MyMigrator());
$this->addBeforeTask(new SetupTask());
}
}
Register Migrations
Configure migrations in config/packages/fregata.yaml:
fregata:
migrations:
- MyApp\Migration\MyMigration
Asynchronous Execution
/fregata/run/{id}) or CLI:
php bin/console messenger:consume async -vv
Synchronous Execution (Debugging)
Use the --synchronous flag for testing:
php bin/console fregata:migration:execute --synchronous
Dependency Management
A must run before B if B depends on A).UI Features
pending, running, completed).BeforeTasks, Migrators, and AfterTasks.running.Customizing the UI
Extend Twig templates in templates/FregataBundle/ to modify layouts or add fields (e.g., custom run metadata).
Logging Use Symfony’s logger in migrators/tasks:
$this->logger->info('Migration step completed', ['migration' => $this->getName()]);
Messenger Transport Misconfiguration
async) isn’t properly configured.MESSENGER_TRANSPORT_DSN (e.g., doctrine://default) and run:
php bin/console messenger:setup-transports
Database Schema Mismatch
EntityManager errors.make:migration + migrations:migrate after installing the bundle.Synchronous Mode Limitations
--synchronous bypasses the UI and database tracking.Circular Dependencies
dependsOn() explicitly.Check Messenger Queue Inspect pending messages:
php bin/console messenger:failed:list
php bin/console messenger:failed:retry [message-id]
Enable Debug Mode
Add to config/packages/dev/fregata.yaml:
fregata:
debug: true
This logs detailed migration steps to var/log/dev.log.
UI Debugging
php bin/console cache:clear
var/log/dev.log.Custom Run Metadata
Extend the Run entity (e.g., src/Entity/FregataRunExtension) to add fields like priority or user_id.
Custom UI Components
Override Twig templates (e.g., templates/FregataBundle/run/index.html.twig) to add buttons or fields.
Pre/Post-Hooks Use Symfony events to intercept migration runs:
// config/services.yaml
services:
App\EventListener\FregataListener:
tags:
- { name: kernel.event_listener, event: fregata.migration.run.started, method: onRunStarted }
Custom Transports
Route FregataMessageInterface to a custom transport (e.g., Kafka) by modifying messenger.yaml.
How can I help you explore Laravel packages today?