Installation Replace with the maintained fork:
composer require skfoxvn/propel-bundle
Add to config/bundles.php:
return [
// ...
SkyFoxvn\PropelBundle\PropelBundle::class => ['all' => true],
];
Configuration
Update config/packages/propel.yaml (auto-generated):
propel:
dbal_connection: default
runtime: ~ # Auto-detected or set to 'php'/'xml'
schema_dir: '%kernel.project_dir%/src/Resources/schema'
migrations_dir: '%kernel.project_dir%/src/Migrations'
First Use Case: Generate Models Run schema generation from XML:
php bin/console propel:build --schema=src/Resources/schema.xml
Verify models in src/Entity/ (Propel-generated).
Schema-Driven Development
BundleName/Resources/schema.xml (XML-only, no YAML).php bin/console propel:build --schema=path/to/schema.xml --write-sql
Database Operations
php bin/console propel:migration:diff
php bin/console propel:migration:migrate
php bin/console propel:reverse --connection=default --output-dir=src/Resources
Querying
UserQuery::create()->find()).ParamConverter for actions:
use Propel\Runtime\ParamConverter\PropelParamConverter;
// services.yaml
Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener:
arguments:
- ['propel' => PropelParamConverter]
Forms & Validation
$form = $this->createForm(PropelFormType::class, $user);
@assert("email", "NotBlank")).Fixtures
php bin/console propel:fixtures:load --append
PropelBundle\Bridge\Doctrine\PropelEntityManager for hybrid apps.UserQuery with Symfony’s security component:
# security.yaml
providers:
propel_user_provider:
entity: { class: User, property: username }
propel.profiler.enabled: true in config.Deprecation Warning
Schema Generation Quirks
schema.xml namespaces match your bundle’s autoloader.--write-sql first to preview SQL changes.Runtime Configuration
runtime: php vs xml:
php: Faster (runtime parsing), but requires propel.php config.xml: Slower (parses schema on each request), but avoids PHP config.php bin/console debug:config propel
Migrations Gotchas
php bin/console propel:migration:check
Symfony Integration
sensio_framework_extra bundle.Symfony\Component\Form\FormInterface (use PropelFormType).propel:
logging: true
php bin/console propel:schema:validate
php bin/console cache:clear
Custom Query Classes
Extend BaseQuery for reusable queries:
class UserQuery extends BaseUserQuery {
public static function activeUsers() {
return self::create()->filterByIsActive(true);
}
}
Event Listeners
Hook into Propel’s lifecycle (e.g., postInsert):
use Propel\Runtime\Connection\ConnectionInterface;
class MyListener {
public function postInsert(ConnectionInterface $con, Model $obj) {
// Custom logic
}
}
Register in services.yaml:
services:
App\Listener\MyListener:
tags:
- { name: propel.listener, event: postInsert }
Custom Fixtures
Extend PropelFixturesLoader for complex data:
use Propel\Runtime\Connection\ConnectionInterface;
class CustomFixturesLoader extends PropelFixturesLoader {
protected function load(ConnectionInterface $con) {
// Custom fixture logic
}
}
How can I help you explore Laravel packages today?