Where can I use Laravel Facade aliases? -


i have built laravel 5.4 application custom facade, app\facades\repo. repo facade proxies repositoryfactory class. in app configuration have alias repo points repo facade. use repositories calls such repo::get('user').

this works fine if in controller or routes file. in other parts of application however, can't use repo alias. interpreter looks repo class in current namespace, , errors out. raises 2 questions:

  • which classes aware of facade aliases? defines them?
  • in classes not aware of facade aliases, should go ahead , import facade class itself? or code smell?

by way of example, classes not alias-aware include repositories themselves. have created super-type them, don't inherit laravel class. repositories need call on other repositories work.

what noticed far (working laravel 5.2) when inside namespaced context need either have use repo; or precede facade slash, \repo::get("user").

out of namespaced context, in routes.php, config files, or views, facade works directly.

but has more how php works laravel itself.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -