-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
1. Start a new project with Maravel
2. Optimize your new project with Maravel
3. Restrict routes by domain with Maravel
Run in terminal:
composer create-project macropay-solutions/maravel your-project-nameor download the zip project, extract it and rename its folder.
Run in terminal:
composer installStart building your project.
Optionally we recommend you to use our AUTO cruFd libs suite by running in terminal:
composer require --dev macropay-solutions/laravel-crud-wizard-generatorThe generator will help you generate the cruFd classes required for exposing an already existing table via API.
composer require macropay-solutions/laravel-crud-wizard-decorator-freeThe decorator will require also macropay-solutions/laravel-crud-wizard-free which contains important retroactive bug fixes and useful new features. See their documentation for more info on how to use them.
On each deploy cache your routes and configs in php files by running:
php artisan route:cachephp artisan config:cacheThese will create cached php files in bootstrap/cache folder.
Note that nikic/fast-route package will also create its cache route php file on first access of a dynamic route.
Create a new middleware:
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class DomainMiddleware
{
public function handle(Request $request, Closure $next, string $urlEncodedCsvUrls): mixed
{
if (\str_contains(\urldecode($urlEncodedCsvUrls), $_SERVER['HTTP_HOST'] ?? '*')) {
return $next($request);
}
return \response(status: 404);
}
}Add in bootstrap/app.php:
$app->routeMiddleware([
'url.encoded.domains' => \App\Http\Middleware\DomainMiddleware::class,
]);Add in routes/web.php:
$router->group(
[
'middleware' => [
'url.encoded.domains:' . \urlencode(\rtrim(\env('APP_URL2'), ',') . ',' . \env('APP_URL'))
],
function (Router $router): void {
$router->post('/login', 'Auth\AuthController@login');
}
);Note that the routes MUST NOT OVERLAP from one domain group to another so, make sure each group of domains uses its own prefix.