I am trying to register an Alias to a class, but Laravel can't find the class, i can reference the class directly in my controller, so i know its loaded correctly.
here is my code:
'aliases' => array(
'FrontendAssets' => 'Lib\FrontendAssets',
)
the class I am trying to make an alias for
class FrontendAssets{
protected static $styles = [];
protected static $scripts = [];
public static function styles(){
return static::assets(static::$styles);
}
public static function addStyle($style){
static::$styles[] = $style;
}
public static function scripts(){
$scripts = static::assets(static::$scripts);
return $scripts;
}
public static function addScript($script){
static::$scripts[] = $script;
}
public static function assets($assets){
return array_map(function ($asset){
return $asset;
}, array_unique($assets));
}
}
This is what i am trying to call in my controller
FrontendAssets::assets();
I have tried adding namespaces but still no joy.
If i use \FrontendAssets::assets();
in my controller, I can use the class so I know it is defiantly been loaded
php artisan config:clear
Might help also. In case you have previously cached config files with config:cache
since aliases are defined in app config.