-
-
Save soediro/b8b16cd1618f052b2ef2f9b626def5f5 to your computer and use it in GitHub Desktop.
Revisions
-
andy-williams revised this gist
Jan 2, 2017 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,10 +4,12 @@ ### install global installer `composer global require "laravel/lumen-installer"` `composer global require "laravel/installer"` ### start new project `lumen new {project-name}` `laravel new {project-name}` ### start app -
andy-williams revised this gist
Jan 2, 2017 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,14 @@ # Lumen / Laravel Cheat sheet ## Install Lumen / Laravel ### install global installer `composer global require "laravel/lumen-installer"` `composer global require "laravel/installer"` ### start new project `lumen new {project-name}` `laravel new {project-name}` ### start app `php -S localhost:8000 -t public` -
andy-williams revised this gist
Dec 31, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # Lumen / Laravel Cheat sheet ## Install Lumen ### install global lumen installer -
andy-williams revised this gist
Dec 31, 2016 . 1 changed file with 66 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -54,10 +54,74 @@ $url = route('profile'); ### Route Groups Allows a group of routes to share namespaces, prefix and middleware #### Middleware $app->group(['middleware' => 'auth'], function () use ($app) { $app->get('/', function () { // Uses Auth Middleware }); $app->get('user/profile', function () { // Uses Auth Middleware }); }); #### Base Route / Prefix $app->group(['prefix' => 'accounts/{account_id}'], function ($app) { $app->get('detail', function ($account_id) { // Matches The accounts/{account_id}/detail URL }); }); ## Middleware 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. ### Creating a Middleware <?php namespace App\Http\Middleware; use Closure; class MyMiddleware { public function handle($request, Closure $next) { // before $response = $next($request); // after return $response; } } ### Using a Middleware #### All Requests $app->middleware([ App\Http\Middleware\App\Http\Middleware\MyMiddleware::class ]); #### Only Certain Routes $app->routeMiddleware([ 'middleware' => App\Http\Middleware\App\Http\Middleware\MyMiddleware::class ]); -
andy-williams revised this gist
Dec 31, 2016 . 1 changed file with 42 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,3 +19,45 @@ `$config_key = env('{config-key}')` ## Routing **Note: Route parameters cannot contain the - character. Use an underscore (_) instead.** ### Verbs $app->get($uri, $callback); $app->post($uri, $callback); $app->put($uri, $callback); $app->patch($uri, $callback); $app->delete($uri, $callback); $app->options($uri, $callback); ### Route Parameters $app->get('user/{id}, function(Request $req, $id) { // } ### Constrained Route Parameters $app->get('user/{name:[A-Za-z]+}', function ($name) { // }); ### Named Routes $app->get('profile', ['as' => 'profile', function (Request $req) { // }]); $url = route('profile'); ### Base Route / Prefix $app->group(['prefix' => 'accounts/{account_id}'], function ($app) { $app->get('detail', function ($account_id) { // Matches The accounts/{account_id}/detail URL }); }); -
andy-williams revised this gist
Dec 31, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ ## Install Lumen ### install global lumen installer `composer global require "laravel/lumen-installer"` ### start new lumen project -
andy-williams created this gist
Dec 31, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ ## Install Lumen ### install global install `composer global require "laravel/lumen-installer"` ### start new lumen project `lumen new {project-name}` ### start app `php -S localhost:8000 -t public` ## Config ### change config `.env` in `root dir` ### access config `$config_key = env('{config-key}')`