<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ixianming / laravel-route-service-provider example snippets
'providers' => [
/*
* Laravel Framework Service Providers...
*/
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
// App\Providers\RouteServiceProvider::class,
Ixianming\Routing\RouteServiceProvider::class,
]
if (method_exists(\Ixianming\Routing\ExceptionResponse::class, 'wantsJson')) {
list($request, $exception) = \Ixianming\Routing\ExceptionResponse::wantsJson($request, $exception);
}
public function render($request, Exception $exception)
{
// Your code ...
// Your code must precede this function.
if (method_exists(\Ixianming\Routing\ExceptionResponse::class, 'wantsJson')) {
list($request, $exception) = \Ixianming\Routing\ExceptionResponse::wantsJson($request, $exception);
}
// There should be no code between the function and `return`.
return parent::render($request, $exception);
}
protected function customMiddlewareGroupsConfig()
{
return array(
'{middlewareGroupName}' => array(
'namespace' => '',
'domain' => '',
'prefix' => '',
'name' => '',
'where' => [],
'eJsonResponse' => false,
'matchRule' => function ($fileRelativePath) {
// your code ...
// The return value must be a boolean.
return false;
}
)
// ...
);
}
//e.g.
//Custom matching rules for web middleware groups
'web' => array(
'matchRule' => function ($fileRelativePath) {
$fileRelativePath = strtolower($fileRelativePath); //Turn lowercase
if (Str::endsWith($fileRelativePath, '_web.php')) {
//If the routing file ends in `_web.php`, it is assigned to the web middleware group
return true;
} else {
return false;
}
}
)
shell
php artisan route:cache
shell
php artisan route:clear
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.