composer global require "laravel/lumen-installer"
composer global require "laravel/installer"
lumen new {project-name}
laravel new {project-name}
php -S localhost:8000 -t public
.env
in root dir
$config_key = env('{config-key}')
Note: Route parameters cannot contain the - character. Use an underscore (_) instead.
$app->get($uri, $callback);
$app->post($uri, $callback);
$app->put($uri, $callback);
$app->patch($uri, $callback);
$app->delete($uri, $callback);
$app->options($uri, $callback);
$app->get('user/{id}, function(Request $req, $id) {
//
}
$app->get('user/{name:[A-Za-z]+}', function ($name) {
//
});
$app->get('profile', ['as' => 'profile', function (Request $req) {
//
}]);
$url = route('profile');
Allows a group of routes to share namespaces, prefix and middleware
$app->group(['middleware' => 'auth'], function () use ($app) {
$app->get('/', function () {
// Uses Auth Middleware
});
$app->get('user/profile', function () {
// Uses Auth Middleware
});
});
$app->group(['prefix' => 'accounts/{account_id}'], function ($app) {
$app->get('detail', function ($account_id) {
// Matches The accounts/{account_id}/detail URL
});
});
A middleware is a layer that lives between the web request handler (web server)
and the router and controller
.
request -> middleware -> routing/controller
This allows you to modify the request before being passed to the controller, check for tokens
, start a timer before and stop after allowing you to log how long the controller takes etc.