I am developing a large system in Laravel. The idea is to create modules and add them to their own repository. I want to make it as generic as possible.
The problem is with the(view)namespaces of laravel. I want to give the user of the package the ability to change the path of the views and if he wants the namespace of the views (Give it the ability to use functionality but using custom views).
This results in a problem with the blade directives @extends
, @include
and @component
.
Having no way to generic use the view namespaces.
Having to put the namespace first in every blade like this:
@extends('user::layouts.web')
Will give the problem that the namespace can never be changed from configuration files.
Other things i tried was using a constant and config for the namespace.
@extends(App\Providers\UserServiceProvider::MODULE_SLUG.'::layouts.web')
@extends(config('user.module.viewNamespace') . '::layouts.web')
Those 2 work but I do not want to type in the configuration path or Provider namespace every time.
I Think that my best solution is writing custom directives @extends
, @includes
and @components
for every module (this will be done dynamically).
You would get the following directives:
@userExtends
@userInclude
@userComponent
The last problem that I am running into is that I cannot find a way to extend the existing @extends
directive.
Any suggestions?