Install the Bundle Run in your Symfony project root:
composer require common-gateway/klanten-bundle:dev-main
For Dockerized environments:
docker-compose exec php composer require common-gateway/klanten-bundle:dev-main
Install Entities & Schemas Execute the installation command to generate entities and database schemas:
php bin/console commongateway:install common-gateway/klanten-bundle
Or in Docker:
docker-compose exec php bin/console commongateway:install common-gateway/klanten-bundle
Verify Installation Check if the bundle’s routes, entities, and migrations are registered:
php bin/console debug:container | grep klanten
First Use Case: CRUD Operations
The bundle likely includes a Klanten entity (Dutch for "clients"). Test basic CRUD via:
php bin/console make:crud KlantenBundle:Klanten
(If the bundle provides a custom API, refer to its src/Resources/config/routes.yaml.)
Plugin-Based Architecture
Klanten entities as user providers:
# config/packages/security.yaml
providers:
klanten_provider:
id: KlantenBundle\Security\KlantenUserProvider
Command-Driven Setup
commongateway:install command to automate schema/entity generation. Override it in your bundle:
// src/Command/InstallCommand.php
class InstallCommand extends CommonGatewayInstallCommand {
protected function configure(): void {
$this->setName('app:install-klanten');
}
}
Event Listeners for Integration
Klanten changes. Example:
// src/EventListener/KlantenListener.php
class KlantenListener implements EventSubscriber {
public static function getSubscribedEvents(): array {
return [
KernelEvents::VIEW => ['onKernelView', 20],
];
}
public function onKernelView(ViewEvent $event) { ... }
}
API/Controller Layer
src/Resources/config/routes.yaml) or create custom controllers:
// src/Controller/KlantenController.php
class KlantenController extends AbstractController {
#[Route('/api/klanten', name: 'klanten_list')]
public function list(KlantenRepository $repo): Response {
return $this->json($repo->findAll());
}
}
Doctrine Entity Extensions
Klanten entity with custom fields or behaviors:
// src/Entity/KlantenExtension.php
#[ORM\Entity]
class KlantenExtension {
#[ORM\ManyToOne(targetEntity: User::class)]
private ?User $owner = null;
}
php bin/console doctrine:migrations:diff after installing the bundle to generate migrations for new tables.composer.json for extra.symfony.endpoint or extra.symfony.recipe.public function testKlantenEntity(): void {
$klant = new Klanten();
$this->assertInstanceOf(Klanten::class, $klant);
}
config/packages/translation.yaml:
imports:
- { resource: "@KlantenBundle/Resources/config/translation.yaml" }
Dev-Main Dependency
dev-main. Ensure your composer.json has:
"minimum-stability": "dev",
"prefer-stable": false
Namespace Collisions
KlantenBundle namespace. If your project also uses Klanten, rename the bundle’s namespace in composer.json:
"autoload": {
"psr-4": {
"App\\": "src/",
"CommonGateway\\Klanten\\": "vendor/common-gateway/klanten-bundle/src/"
}
}
Missing Documentation
@todo!). Assume the bundle provides:
Klanten entity with basic fields (e.g., name, email, createdAt)./klanten.src/Resources/config/doctrine/ for entity definitions.Command Overrides
commongateway:install, ensure your command’s class is autoloaded. Add to composer.json:
"autoload-dev": {
"psr-4": {
"App\\Command\\": "src/Command/"
}
}
Doctrine Lifecycle Callbacks
@ORM\PrePersist). Test these with:
$klant = new Klanten();
$entityManager->persist($klant);
$entityManager->flush(); // Triggers callbacks
Check Bundle Registration
php bin/console debug:container KlantenBundle
config/bundles.php:
return [
// ...
CommonGateway\KlantenBundle\KlantenBundle::class => ['all' => true],
];
Database Schema Issues
php bin/console doctrine:schema:update --dump-sql
src/Resources/config/doctrine/Klanten.orm.xml.Route Conflicts
php bin/console debug:router | grep klanten
# config/routes.yaml
_klanten:
resource: "@KlantenBundle/Resources/config/routes.yaml"
prefix: "/admin" # Isolate routes
Event Dispatcher Issues
$dispatcher->addListener(KernelEvents::CONTROLLER, function (ControllerEvent $event) {
error_log("Controller: " . $event->getController()[0]::class);
});
Custom Entities
Klanten entity by creating a new entity that references it:
#[ORM\Entity]
class ClientProfile {
#[ORM\OneToOne(targetEntity: Klanten::class, inversedBy: "profile")]
private ?Klanten $klanten;
}
API Platform Integration
Klanten entity:
# config/api_platform/resources.yaml
resources:
CommonGateway\KlantenBundle\Entity\Klanten:
collectionOperations:
get:
method: GET
path: /klanten
Symfony UX Integration
{# templates/klanten/index.html.twig #}
<turbo-frame id="klanten-list">
{% for klant in klanten %}
<div>{{ klant.name }}</div>
{% endfor %}
</turbo-frame>
Messenger Integration
Klanten entities are created/updated:
$klant->addEvent(new KlantenCreatedEvent($klant));
$dispatcher->dispatch($klant->getEvents());
Custom Admin UI
mkdir -p templates/bundles/KlantenBundle/
cp vendor/common-gateway/klanten-bundle/templates/* templates/bundles/KlantenBundle/
How can I help you explore Laravel packages today?