Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Shell Alias Bundle Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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:

  1. Require it (Symfony2 era, so pin explicitly): composer require "servergrove/shell-alias-bundle:~1.0" — or dev-master if no tag resolves.
  2. Register it in app/AppKernel.php inside registerBundles():
    new ServerGrove\Bundle\ShellAliasBundle\ServerGroveShellAliasBundle(),
    
  3. Run 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.
  4. Redirect the output once to see the shape before wiring anything:
    php app/console shell-alias:generate > /tmp/aliases.sh
    cat /tmp/aliases.sh
    
  5. First real use case: source it from your shell rc so 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.

Implementation Patterns

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.

Gotchas and Tips

  • Dead on modern Symfony. It hooks into 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.
  • Aliases are snapshots. Add a bundle, and your alias file is silently stale. There is no auto-refresh; wire regeneration into install/pull or you'll chase phantom commands.
  • Aliases don't work in scripts. Alias expansion is interactive-shell only. Makefiles, CI, sh -c, and cron get nothing — use shell functions or the full php app/console … there.
  • Quoting and reserved characters. Generated lines containing paths with spaces or command arguments need single quotes around the value. Commands with : are fine in an alias name; =, /, and whitespace are not. Inspect output before sourcing.
  • Collisions fail silently. A later 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.
  • Color/ANSI in output. If the generator decorates output, you'll write escape codes into your rc file. Always generate with --no-ansi (and check the command supports it).
  • bash vs zsh. alias syntax is shared, but completion setup differs (compdef vs complete). zsh users often prefer functions with $@ passthrough so arguments and completion both work.
  • Extension point. If alias naming doesn't fit, override the command service in services.xml or extend the command class and swap the naming method — don't patch vendor/, or your next composer update reverts it.
  • Debugging checklist. 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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource