lilaconcepts/lilaconceptsbestpracticebundle
A Laravel/PHP package that bundles best-practice defaults for cleaner, more maintainable applications. It gathers recommended conventions and quality tooling in one place, helping teams standardize code and reduce setup friction across projects.
This is a Symfony 2.1 bundle, not a Laravel package. Treat it as a reference implementation and scaffold, not a runtime dependency. The single most valuable move is to clone it locally and read it as a "here is what a well-structured, tested, CI-backed bundle looks like" document.
Minimal steps:
git clone https://github.com/lilaconcepts/lilaconceptsbestpracticebundle somewhere outside your app — do not composer require it into a Laravel project (the Symfony 2.1 constraints will fight your framework).composer.json — package name, autoload PSR-0/PSR-4 mapping, require-dev (PHPUnit, Symfony).LilaconceptsBestPracticeBundle.php — the bundle class itself (thin, as it should be).DependencyInjection/ — the Extension and Configuration classes; this is the pattern most Laravel devs need to internalize.Resources/config/services.yml — service wiring.Tests/ — split into Unit/ and Functional/, plus the Tests/Fixtures/ kernel used by functional tests.phpunit.xml.dist and .travis.yml — the test-runner and CI scaffolding.packages/vendor/name/ and adapt).If you're a Laravel dev who has to touch a legacy Symfony app, this bundle doubles as a Rosetta Stone: every concept here has a direct Laravel analogue (see below).
Bundle registration (Symfony side). The bundle is inert until added to app/AppKernel.php:
$bundles = [
// ...
new Lilaconcepts\BestPracticeBundle\LilaconceptsBestPracticeBundle(),
];
Day-to-day, once registered, you interact with it through the container and Twig — not by instantiating classes.
DI Extension pattern → Laravel ServiceProvider analogue. The DependencyInjection/*Extension.php loads YAML service definitions and merges/prepends config; the Configuration.php defines the config tree (defaults, validation, env vars). This is the exact job of a Laravel ServiceProvider::register() + config/packages/*.php file. When porting a pattern to Laravel, map:
| Symfony bundle | Laravel equivalent |
|---|---|
*Bundle.php + *Extension.php |
ServiceProvider |
DependencyInjection/Configuration.php |
config/your-package.php |
Resources/config/services.yml |
bindings in register() |
Resources/views/*.twig |
resources/views/*.blade.php |
Tests/Functional/* (WebTestCase) |
Feature tests hitting routes |
Tests/Unit/* |
Unit tests |
.travis.yml |
.github/workflows/*.yml |
Service wiring. Define services in Resources/config/services.yml, inject dependencies via constructor arguments, and let the container autowire where the Symfony version allows. Prefer constructor injection over $container->get() calls; the latter is the fastest way to make a bundle untestable.
Twig extension pattern. If the bundle exposes template helpers, look at how a TwigExtension is registered as a service tagged twig.extension. The Laravel mirror is a Blade directive or a view composer.
Functional test workflow. The Tests/Fixtures/ mini-app (kernel + config) is the important trick: functional tests boot a real kernel and issue requests via WebTestCase. Copy this harness when you build your own bundle. Run with:
composer install
vendor/bin/phpunit
and mirror the same command in CI so local and remote stay aligned.
Fork-and-rebrand workflow (most common day-to-day use).
Lilaconcepts\BestPracticeBundle → YourVendor\YourBundle) with sed/IDE refactor.composer.json (name, autoload, require-dev) and the phpunit.xml.dist bootstrap path.bin/console boots without a container error.Integration tip. Keep your bundle thin and additive: services, a Twig extension, one or two commands. Don't let the bundle reach into app-level config; expose configuration via Configuration.php and let the app opt in. Same discipline you'd apply to a Laravel package that shouldn't call app() everywhere.
composer require it into a Laravel project. Symfony 2.1 constraints (symfony/* ~2.1, old PHPUnit, PHP ~5.3/5.4) will conflict with modern framework versions and Composer will either fail or drag in ancient transitive deps. Use it as source material only, or install it inside a throwaway Symfony 2.1 VM if you must run it.setUp signatures, deprecations).Tests/Fixtures/; if you rename namespaces and forget to update the fixture kernel's registerBundles() and the phpunit.xml.dist bootstrap path, tests fail with a confusing "class not found" rather than a meaningful assertion error.Bundle, live in the namespace declared in composer.json, and match the directory name. The DI extension alias is derived from the bundle name (underscore-cased) — if services aren't being found, check the alias in getAlias() first..travis.yml is dead weight now. Travis CI is effectively retired for new OSS. Replace it with a GitHub Actions workflow: shivammathur/setup-php, composer install --prefer-dist, vendor/bin/phpunit. Keep the same test command so local/CI parity holds.Configuration.php tree-builder defaults silently win over what you think you passed. When a config value "isn't taking effect," dump the processed container config (bin/console config:dump-reference / debug:container) before touching YAML.app/Resources/<BundleName>/views/. Getting the path wrong is a silent fallback to the bundle default — verify the resolved path in the profiler.artisan, no dd(), no Tinker. Use bin/console debug:container, debug:router, the web profiler, and var_dump + exit in a pinch. For Laravel devs this is the steepest day-one adjustment.CompilerPassInterface) for conditional service wiring, service tags for opt-in behavior, and bundle inheritance for template overrides. These are the seams to use instead of editing bundle internals — the same reason you'd write a Laravel macro instead of patching vendor code.How can I help you explore Laravel packages today?