I’m currently developing an internal Laravel package which is used in more than five applications. I register two middleware component in a service provider in the package:
public function boot()
{
/** @var Router $router */
$router = $this->app['router'];
$router->pushMiddlewareToGroup('web', ComponentOne::class);
$router->pushMiddlewareToGroup('web', ComponentTwo::class);
$router->pushMiddlewareToGroup('api', ComponentOne::class);
$router->pushMiddlewareToGroup('api', ComponentTwo::class);
}
Is there a possibility to configure priority within the package itself? Component one must be executed before component two. The only thing that I found up till now is configure the Kernel class for each application that uses this package:
protected $middlewarePriority = [
ComponentOne::class,
ComponentTwo::class,
];