Home » Php » php – Add a global namespace for all blade views

php – Add a global namespace for all blade views

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have a large number of views in my app and now I have implemented a class that I will use in most of the views through the app.

Is there a way to add a global namespace to be available in all views?

Example:

I’m having to add use App\Helpers\PermissionHelper; in views, I want to use class PermissionHelper. I would like to add it globally so I could use that class without adding the namespace in all cases.

Update

I used to work with ASP.Net MVC and it has a section in its web.config(a global setup for the whole project) where you can add namespaces to be automatically available in files(like views), like this.

How to&Answers: