
use alias for namespace and class once for all in php
in this short article i introduce a better way for using namespaced classes .
if you are sick using
use Vendor\Something\OtherThing\MyClass as MyClass
then this article is the answer to your problem .
first of all I use composer for my dependency management .
what i`ve done were creating a file named Alias.php . and inside of it
i created an array of aliases and classes with namespaces
$aliases = array(
“Blade” => “Philo\Blade\Blade”
“Form” => ”Form\Form”
…
and at the bottom of the Alias.php file i did a foreach upon $aliases like below
foreach( $aliases as $alias => $full )
{class_alias ( $full , $alias , true );
}

okay . we are done with the Alias.php file .
now we have to execute this file whenever a request comes in .
open your composer.json file and add some rules
inside of autoload section
add
“files”:[“config/Alias.php”]
and your are set to go