davejamesmiller/laravel-aliases

Adds an 'artisan aliases' command to Laravel that lists registered aliases and the classes they map to, including resolving facades.

1.0.1 2013-11-24 10:22 UTC

README

Adds an artisan aliases command to Laravel 4 that lists registered aliases and the classes they map to, including resolving facades.

This saves you having to look them up, and works with custom aliases and facades as well. It's also easier than calling getFacadeRoot() manually and gives you more detail about the class hierarchy.

Installation

1. Install with Composer

composer require davejamesmiller/laravel-aliases dev-master

This will update composer.json and install it into the vendor/ directory.

Note: dev-master is the latest development version. See the Packagist website for a list of other versions.

2. Add to app/config/app.php

    'providers' => array(
        // ...
        'DaveJamesMiller\Aliases\AliasesServiceProvider',
    ),

This registers the Artisan task with Laravel.

Usage

Show all aliases

$ php artisan aliases

e.g.

App
-> Illuminate\Support\Facades\App
-> Illuminate\Foundation\Application
-> Illuminate\Container\Container

Artisan
-> Illuminate\Support\Facades\Artisan
-> Illuminate\Console\Application
-> Symfony\Component\Console\Application

...

Show alisases starting with "re"

$ php artisan aliases re

e.g.

Redirect
-> Illuminate\Support\Facades\Redirect
-> Illuminate\Routing\Redirector

Redis
-> Illuminate\Support\Facades\Redis
-> Illuminate\Redis\Database

Request
-> CustomRequest
-> Illuminate\Support\Facades\Request
-> Illuminate\Http\Request
-> Symfony\Component\HttpFoundation\Request

Response
-> Illuminate\Support\Facades\Response

Verbose option shows how classes are resolved

$ php artisan aliases -v re

e.g.

Redirect
alias   > Illuminate\Support\Facades\Redirect
facade  > App::make('redirect')
resolve > Illuminate\Routing\Redirector

Redis
alias   > Illuminate\Support\Facades\Redis
facade  > App::make('redis')
resolve > Illuminate\Redis\Database

Request
alias   > CustomRequest
parent  > Illuminate\Support\Facades\Request
facade  > App::make('request')
resolve > Illuminate\Http\Request
parent  > Symfony\Component\HttpFoundation\Request

Response
alias   > Illuminate\Support\Facades\Response

Changelog

0.1.0

  • Initial release

0.2.0

  • Show how facades are resolved when using verbose (-v) flag (e.g. App::make('url'))

1.0.0

Version bump - no changes.

1.0.1

  • Compatibility with Laravel 4.1.

Thanks to

I got the idea from this Fideloper blog post, and worked out how to implement it by looking at this phpDoc generator by barryvdh.

License

MIT License. See LICENSE.txt.