c33s/construction-kit-bundle
Installation:
composer require c33s/construction-kit-bundle
Add to config/bundles.php:
return [
// ...
C33s\ConstructionKitBundle\C33sConstructionKitBundle::class => ['all' => true],
];
Define a Building Block:
Create a YAML file (e.g., config/construction_kit/blocks/my_block.yml):
my_block:
type: bundle
bundle: Symfony\Bundle\FrameworkBundle\FrameworkBundle
config:
router:
resource: "%kernel.project_dir%/config/routes.yml"
Apply the Block: Use the CLI command to apply blocks to a project:
php bin/console construction-kit:apply my_block
First Use Case: Reuse a common configuration (e.g., security, routing) across multiple Symfony projects without manual setup.
Resources/doc/ directory (if available) for block types (bundle, asset, config).config/construction_kit/ for pre-defined blocks.php bin/console list construction-kit
Bundle Reusability:
FOSUserBundle) with its config in construction_kit/blocks/fos_user.yml:
fos_user:
type: bundle
bundle: FOS\UserBundle\FOSUserBundle
config:
fos_user:
db_driver: orm
firewall_name: main
construction-kit:apply fos_user.Asset Management:
# config/construction_kit/blocks/assets.yml
project_assets:
type: asset
source: "%kernel.project_dir%/src/Resources/public/assets"
destination: "%kernel.project_dir%/web/assets"
construction-kit:apply project_assets.Config Snippets:
# config/construction_kit/blocks/doctrine.yml
doctrine:
type: config
target: config/packages/doctrine.yaml
content: |
doctrine:
dbal:
url: "%env(DATABASE_URL)%"
Project Templates:
php bin/console construction-kit:apply base_template
Centralized Block Repository:
company-construction-kit).config/construction_kit/ of each project.Versioned Blocks:
v1.0.0) and reference them in projects:
my_block:
version: v1.0.0
Conditional Application:
debug_tools:
type: bundle
bundle: Symfony\WebProfilerBundle\WebProfilerBundle
enabled: "%kernel.debug%"
Post-Apply Hooks:
ConstructionKitEvents to run custom logic after applying blocks (e.g., cache clearing):
// src/EventListener/ConstructionKitListener.php
public function onPostApply(PostApplyEvent $event) {
$this->container->get('cache_clearer')->clear();
}
Symfony Flex:
symfony/flex for dynamic bundle installation:
# config/construction_kit/blocks/symfony_flex.yml
symfony_flex:
type: command
command: composer require symfony/orm-pack
Propel ORM:
type: propel block for Propel-specific configs (if extended):
propel:
type: propel
config:
propel:
database:
connections:
default:
adapter: mysql
CI/CD Pipelines:
# deploy.sh
git clone company-construction-kit config/construction_kit
php bin/console construction-kit:apply --all
Custom Block Types:
database, environment):
// src/DependencyInjection/Compiler/BlockTypePass.php
public function process(ContainerBuilder $container) {
$definition = $container->findDefinition('construction_kit.block_type');
$definition->addMethodCall('addType', ['database', new Reference('app.database_block')]);
}
Overwriting Configs:
config/packages/*.yaml may overwrite existing configs. Use !import or merge strategies:
# construction_kit/blocks/doctrine.yml
doctrine:
type: config
target: config/packages/doctrine.yaml
strategy: merge
content: |
doctrine:
orm:
mappings:
App:
is_bundle: false
Circular Dependencies:
block_a depends on block_b, which depends on block_a) will fail silently. Validate block graphs:
php bin/console construction-kit:validate
File Permissions:
web/ or var/ may fail due to permissions. Set up proper ownership:
chown -R www-data:www-data config/construction_kit
Propel-Specific Issues:
propel:build command is run post-application:
php bin/console construction-kit:apply propel_config && php bin/console propel:build
Dry Runs:
php bin/console construction-kit:apply my_block --dry-run
Verbose Output:
php bin/console construction-kit:apply my_block -vvv
Event Listeners:
public function onPreApply(PreApplyEvent $event) {
error_log("Applying block: " . $event->getBlockName());
}
Block Validation:
php bin/console construction-kit:validate my_block
Parameter Placeholders:
%kernel.project_dir% or custom parameters in block configs:
assets:
type: asset
source: "%construction_kit.assets.source%"
config/packages/construction_kit.yaml:
construction_kit:
assets:
source: "%kernel.project_dir%/src/Resources/public"
Environment-Specific Blocks:
%env() in block configs for environment variables:
database:
type: config
target: config/packages/doctrine.yaml
content: |
doctrine:
dbal:
url: "%env(DATABASE_URL)%"
Block Inheritance:
# base.yml
base_config:
type: config
content: |
framework:
secret: "%env(APP_SECRET)%"
# app.yml
app_config:
extends: base_config
content: |
framework:
http_method_override: true
Custom Block Types:
C33s\ConstructionKitBundle\Block\BlockTypeInterface:
class DatabaseBlockType implements BlockTypeInterface {
public function apply(Block $block, Project $project) {
// Custom logic (e.g., create SQL dump)
}
}
services.yaml:
services:
app.database_block:
class: App\Block\DatabaseBlockType
tags:
- { name: construction_kit.block_type, type: database }
Block Storage:
// src/DependencyInjection/Compiler/StoragePass.php
public function process(ContainerBuilder $container) {
$
How can I help you explore Laravel packages today?