liip/code-bundle
LiipCodeBundle is a Symfony bundle for displaying and editing source code in your apps. It adds syntax highlighting and code-editor integration, making it easy to embed readable code snippets in templates, documentation, and admin screens.
Verdict up front: liip/code-bundle is not a Laravel package. It is a deprecated Symfony2 bundle (last release 2015-06-15, archived, 25 stars, 0 dependents). For a Laravel developer, its day-to-day leverage is effectively zero as a dependency; its value is as a small reference implementation for building equivalent Artisan commands.
Minimal steps in a legacy Symfony2 app
composer require liip/code-bundle only if you are maintaining a Symfony 2.x application.app/AppKernel.php.README.md for command signatures and editor configuration.Command/ for the actual console commands.DependencyInjection/ and Resources/config/ for service wiring and config keys.app/console list liip:code to discover the available commands.config.yml (typically under liip_code:) and try resolving one service or class to a file path, then opening it.Minimal steps in a Laravel app Do not install it. Instead:
code:find and code:open.class_exists() + ReflectionClass.app()->make() / app()->bound().view()->getFinder()->find().config().Route::getRoutes().config/code.php.First use case: resolve a service ID or class name to its absolute file path, then open it in your editor from the terminal. That is the core workflow the bundle was built around, and it is still a useful pattern in Laravel if you implement it yourself.
Legacy Symfony2 usage pattern
The bundle exposes console commands around a common “identifier → file path/class” workflow. The exact command names should be confirmed via app/console list liip:code, but the pattern is:
# Resolve and locate
app/console liip:code:find class "Acme\DemoBundle\Entity\User"
app/console liip:code:find service "acme.demo.service"
app/console liip:code:find template "AcmeDemoBundle:Default:index.html.twig"
app/console liip:code:find bundle "AcmeDemoBundle"
# Open in configured editor
app/console liip:code:open service "acme.demo.service"
Typical configuration:
# config.yml
liip_code:
editor: phpstorm
# or an explicit command such as:
# editor: "phpstorm --line={line} {file}"
Day-to-day workflow
alias sf-find='app/console liip:code:find'
alias sf-open='app/console liip:code:open'
path=$(app/console liip:code:find template "AcmeDemoBundle:Default:index.html.twig")
grep -R "some_marker" "$path"
Porting the pattern to Laravel
A useful Laravel equivalent is roughly 100 lines and avoids legacy Symfony coupling:
// app/Console/Commands/CodeFind.php
protected $signature = 'code:find {type} {name} {--json}';
protected $description = 'Resolve a class, service, view, config key, or route to a file path';
public function handle()
{
$path = match ($this->argument('type')) {
'class' => (new ReflectionClass($this->argument('name')))->getFileName(),
'service' => (new ReflectionClass(app($this->argument('name'))))->getFileName(),
'view' => view()->getFinder()->find($this->argument('name')),
'config' => $this->resolveConfigFile($this->argument('name')),
'route' => $this->resolveRouteAction($this->argument('name')),
default => null,
};
if (!$path || !is_file($path)) {
$this->error("Not found: {$this->argument('name')}");
return self::FAILURE;
}
$this->line($this->option('json') ? json_encode(['path' => realpath($path)]) : realpath($path));
return self::SUCCESS;
}
Then an code:open command that launches the configured editor:
$template = config('code.editor_command', 'phpstorm --line={line} {file}');
$command = str_replace(['{file}', '{line}'], [escapeshellarg($path), $line ?? 1], $template);
\Symfony\Component\Process\Process::fromShellCommandline($command)->run();
Integration tips
--json) so the command can be consumed by editor plugins, fzf, or scripts.code:find resolver per identifier type rather than a monolithic switch; Laravel’s container and Illuminate\Support\Str make namespace guessing easy.routes/console.php or let Laravel auto-discover them from app/Console/Commands.realpath() and handle Windows path separators if the team is mixed-OS.AcmeDemoBundle:Default:index.html.twig, XML/YAML service definitions, and the old console API do not map cleanly to Laravel’s Blade views, service providers, and container bindings.phpstorm, subl, code) break on other machines. Prefer a configurable command template with {file} and {line} placeholders.exec()/shell_exec() calls. Use escapeshellarg() and Symfony\Component\Process.-vvv, clear the Symfony cache after config changes, confirm the bundle is registered in AppKernel, and check for command-name collisions with other bundles.php artisan code:find class "App\Models\User" as a smoke test, then test views, config, and routes. Add tests for not-found cases and paths containing spaces.barryvdh/laravel-ide-helper, php artisan tinker, PhpStorm’s Symfony/Laravel plugins, fzf, and simple rg/grep aliases cover most of what this bundle offered.How can I help you explore Laravel packages today?