servergrove/shell-alias-bundle
ServerGrove ShellAliasBundle is a Symfony bundle for defining and managing shell aliases from application configuration. It helps generate shell scripts that simplify common terminal commands, reduce typing, and streamline local development and project workflows.
This is a Symfony2 bundle, not a Laravel package — there is no service provider, no config/shell_alias.php, and no php artisan vendor:publish. Treat it as a reference implementation you port, not a dependency you composer require in a modern app. With 0 dependents and a Symfony2-era codebase, the realistic first step is reading the bundle's console command source on GitHub, then reproducing its ~50 lines of logic in your own project.
For a Symfony2 project that actually matches the constraints:
composer require "servergrove/shell-alias-bundle:~1.0" — or dev-master if no tag resolves.app/AppKernel.php inside registerBundles():
new ServerGrove\Bundle\ShellAliasBundle\ServerGroveShellAliasBundle(),
php app/console list and look for the bundle's command under its namespace (something like shell-alias:generate / shell:aliases). That command is the whole product: it walks the application's registered console commands and prints alias lines.php app/console shell-alias:generate > /tmp/aliases.sh
cat /tmp/aliases.sh
php app/console cache:clear becomes a two- or three-letter alias:
echo 'source ~/.symfony_aliases' >> ~/.bashrc
Look first at the command class (Command/ directory) and the bundle's DependencyInjection/Configuration.php. Those two files tell you the alias naming strategy and every knob you can turn — everything else is Symfony boilerplate.
Generate-on-demand, source-on-shell-start. Don't hand-maintain aliases. Wire a generation step and source the artifact:
# regenerate after pulling / adding bundles
php app/console shell-alias:generate > ~/.symfony_aliases
source ~/.symfony_aliases
Add the generation line to your Makefile/composer script so it runs after composer install and after cache:clear when you've added commands.
Per-project files with prefixed alias names. With multiple Symfony apps open, flat aliases collide. Generate one file per project and prefix the alias names with a short project tag (shop-cc, cms-cc). Most implementations let you configure an alias prefix; if not, wrap the command output through sed:
php app/console shell-alias:generate | sed 's/^alias /alias shop-/' > ~/.aliases/shop.sh
Namespace-based shortening. Commands arrive grouped (doctrine:migrations:migrate, cache:clear, assets:install). The useful pattern is mapping the namespace to a one- or two-char prefix and keeping the leaf verb: dmm, cc, ai. Configure namespace→prefix mappings if the bundle exposes them; otherwise fork the naming method — it's the single method worth customizing.
Filter before you generate. A large Symfony2 app registers 150+ commands, most of which you'll never alias (router:debug, third-party bundle commands). Exclude entire namespaces (--exclude=debug,router) so the sourced file stays small and collision-free.
Bash completion alongside aliases. Aliases break tab-completion of arguments. Pair the generated aliases with Symfony's native _console completion script and register it for the console binary; otherwise you've traded typing for guessing.
Port it to Laravel. The same idea is ~30 lines over Artisan::all() in a custom command: iterate commands, skip list/help/vendor namespaces, print alias <short>='php artisan <name>'. That's the durable takeaway from this package.
AppKernel and app/console. It will not boot on Symfony 3+ Flex (bin/console) without edits. If you're on Laravel, don't install it at all — read it and reimplement.sh -c, and cron get nothing — use shell functions or the full php app/console … there.: are fine in an alias name; =, /, and whitespace are not. Inspect output before sourcing.alias cc=... overwrites an earlier one; there's no warning. Before sourcing, check with alias cc / type cc. Use unalias -a cautiously in rc files.--no-ansi (and check the command supports it).alias syntax is shared, but completion setup differs (compdef vs complete). zsh users often prefer functions with $@ passthrough so arguments and completion both work.services.xml or extend the command class and swap the naming method — don't patch vendor/, or your next composer update reverts it.bash -x ~/.symfony_aliases to see sourcing errors; alias with no arguments to list what actually loaded; command <name> to run the underlying binary and confirm it's a name collision rather than a broken alias.How can I help you explore Laravel packages today?