Install via Composer
composer require common-gateway/open-catalogi-bundle:dev-main
composer.json includes the package under require.Run the Installer Command
php bin/console commongateway:install common-gateway/open-catalogi-bundle
Bundle installed successfully).Verify Installation
config/packages/ for new bundle configs (e.g., common_gateway_open_catalogi.yaml).php bin/console doctrine:migrations:migrate
Resources/config/doctrine/ directory.CatalogItem.php) by:
// src/Entity/CustomCatalogItem.php
namespace App\Entity;
use CommonGateway\OpenCatalogiBundle\Entity\CatalogItem;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class CustomCatalogItem extends CatalogItem {
#[ORM\Column]
private string $customField;
}
config/doctrine/orm/auto_mapping.xml to include your namespace.Template-Based Creation
CommonGateway\OpenCatalogiBundle → YourVendor\YourBundle).Dependency Injection
# config/services.yaml
services:
YourVendor\YourBundle\Service\YourService:
arguments:
$catalogService: '@common_gateway_open_catalogi.catalog_service'
Command Integration
commongateway:install command for custom logic:
// src/Command/YourInstallCommand.php
namespace YourVendor\YourBundle\Command;
use CommonGateway\BRPBundle\Command\InstallCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class YourInstallCommand extends InstallCommand {
protected function execute(InputInterface $input, OutputInterface $output): int {
$this->installEntities($output); // Custom logic
return Command::SUCCESS;
}
}
Resources/config/services.yaml:
commands:
YourVendor\YourBundle\Command\YourInstallCommand: ~
Event Listeners
common_gateway.catalog.item.created):
// src/EventListener/CatalogListener.php
namespace YourVendor\YourBundle\EventListener;
use CommonGateway\OpenCatalogiBundle\Event\CatalogItemEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class CatalogListener implements EventSubscriberInterface {
public static function getSubscribedEvents(): array {
return [
CatalogItemEvent::CREATED => 'onItemCreated',
];
}
public function onItemCreated(CatalogItemEvent $event) {
// Custom logic (e.g., log, notify)
}
}
make:migration after modifying entities:
php bin/console make:migration
config/bundles.php:
return [
// ...
YourVendor\YourBundle\YourBundle::class => ['all' => true],
];
$this->container->set(
'common_gateway_open_catalogi.catalog_service',
$this->createMock(CatalogService::class)
);
Namespace Collisions
YourVendor\YourBundle) doesn’t conflict with existing bundles.Acme instead of App).Command Registration
Resources/config/services.yaml will make them unavailable.commands section includes your command class.Doctrine Entity Generation
src/Entity/ without running make:entity or make:migration can break schema updates.php bin/console make:entity YourEntity
Flex Autoloading
src/ may not autoload if composer dump-autoload isn’t run post-install.composer.json scripts:
"post-install-cmd": [
"@composer/symfony-scripts",
"composer dump-autoload"
]
--verbose to debug:
php bin/console commongateway:install --verbose common-gateway/open-catalogi-bundle
@ORM\Entity annotations and mappings in config/packages/doctrine.yaml:
doctrine:
orm:
mappings:
YourBundle: ~
your_vendor.your_bundle.service).Custom Install Steps
InstallCommand to add pre/post-install logic (e.g., database seeding):
protected function installEntities(OutputInterface $output): void {
$this->installDefaultEntities($output);
$this->seedDefaultData($output); // Custom method
}
Dynamic Configuration
ParameterBag to load bundle-specific configs:
$this->container->getParameter('your_bundle.config.key');
config/packages/your_bundle.yaml:
your_bundle:
config:
key: value
API Extensions
// src/Controller/CatalogController.php
namespace YourVendor\YourBundle\Controller;
use CommonGateway\OpenCatalogiBundle\Controller\CatalogController as BaseController;
class CatalogController extends BaseController {
public function customAction(): Response {
// Extend logic
}
}
Resources/config/routing.yaml:
your_bundle_custom:
path: /custom
controller: YourVendor\YourBundle\Controller\CatalogController::customAction
Asset Management
Resources/public/ and using Symfony’s asset system:
{{ asset('bundles/yourbundle/css/style.css') }}
How can I help you explore Laravel packages today?