From 6070d93c4ace42843a68c8adb6c285fe526a4d8e Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 11 Aug 2014 10:13:20 -0500 Subject: [PATCH] Working on new directory structure. --- app/config/app.php | 13 ++- app/config/auth.php | 6 +- app/controllers/.gitkeep | 0 app/controllers/BaseController.php | 18 ---- app/routing/filters.php | 93 ------------------- app/routing/routes.php | 27 ------ app/src/{ => App}/User.php | 5 +- .../Console}/InspireCommand.php | 4 +- .../Http/Controllers}/HomeController.php | 2 +- app/src/Http/Filters/AuthFilter.php | 28 ++++++ app/src/Http/Filters/BasicAuthFilter.php | 15 +++ app/src/Http/Filters/CsrfFilter.php | 21 +++++ app/src/Http/Filters/GuestFilter.php | 18 ++++ app/src/Http/Filters/MaintenanceFilter.php | 18 ++++ app/{commands => src/Http/Requests}/.gitkeep | 0 app/src/Providers/AppServiceProvider.php | 2 +- app/src/Providers/ArtisanServiceProvider.php | 23 +---- app/src/Providers/ErrorServiceProvider.php | 32 +++---- app/src/Providers/FilterServiceProvider.php | 37 ++++++++ app/src/Providers/LogServiceProvider.php | 24 ++--- app/src/Providers/RouteServiceProvider.php | 29 ++++++ app/src/Requests/.gitkeep | 0 bootstrap/paths.php | 16 ++++ composer.json | 13 +-- public/index.php | 1 - 25 files changed, 225 insertions(+), 220 deletions(-) delete mode 100644 app/controllers/.gitkeep delete mode 100644 app/controllers/BaseController.php delete mode 100644 app/routing/filters.php delete mode 100644 app/routing/routes.php rename app/src/{ => App}/User.php (84%) rename app/{commands => src/Console}/InspireCommand.php (84%) rename app/{controllers => src/Http/Controllers}/HomeController.php (92%) create mode 100644 app/src/Http/Filters/AuthFilter.php create mode 100644 app/src/Http/Filters/BasicAuthFilter.php create mode 100644 app/src/Http/Filters/CsrfFilter.php create mode 100644 app/src/Http/Filters/GuestFilter.php create mode 100644 app/src/Http/Filters/MaintenanceFilter.php rename app/{commands => src/Http/Requests}/.gitkeep (100%) create mode 100644 app/src/Providers/FilterServiceProvider.php create mode 100644 app/src/Providers/RouteServiceProvider.php delete mode 100644 app/src/Requests/.gitkeep diff --git a/app/config/app.php b/app/config/app.php index 0a5e64c45..3e254981e 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -98,10 +98,12 @@ return array( /* * Application Service Providers... */ - 'AppServiceProvider', - 'ArtisanServiceProvider', - 'ErrorServiceProvider', - 'LogServiceProvider', + 'Providers\AppServiceProvider', + 'Providers\ArtisanServiceProvider', + 'Providers\ErrorServiceProvider', + 'Providers\FilterServiceProvider', + 'Providers\LogServiceProvider', + 'Providers\RouteServiceProvider', /* * Laravel Framework Service Providers... @@ -109,9 +111,7 @@ return array( 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Auth\AuthServiceProvider', 'Illuminate\Cache\CacheServiceProvider', - 'Illuminate\Session\CommandsServiceProvider', 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', - 'Illuminate\Routing\ControllerServiceProvider', 'Illuminate\Cookie\CookieServiceProvider', 'Illuminate\Database\DatabaseServiceProvider', 'Illuminate\Encryption\EncryptionServiceProvider', @@ -132,7 +132,6 @@ return array( 'Illuminate\Translation\TranslationServiceProvider', 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', - 'Illuminate\Workbench\WorkbenchServiceProvider', ), diff --git a/app/config/auth.php b/app/config/auth.php index eacbbfaed..967e0e258 100644 --- a/app/config/auth.php +++ b/app/config/auth.php @@ -28,7 +28,7 @@ return array( | */ - 'model' => 'User', + 'model' => 'App\User', /* |-------------------------------------------------------------------------- @@ -59,13 +59,9 @@ return array( */ 'reminder' => array( - 'email' => 'emails.auth.reminder', - 'table' => 'password_reminders', - 'expire' => 60, - ), ); diff --git a/app/controllers/.gitkeep b/app/controllers/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/controllers/BaseController.php b/app/controllers/BaseController.php deleted file mode 100644 index 2bee4644a..000000000 --- a/app/controllers/BaseController.php +++ /dev/null @@ -1,18 +0,0 @@ -layout)) - { - $this->layout = View::make($this->layout); - } - } - -} diff --git a/app/routing/filters.php b/app/routing/filters.php deleted file mode 100644 index 908b99edf..000000000 --- a/app/routing/filters.php +++ /dev/null @@ -1,93 +0,0 @@ -info(Inspiring::quote()); + $this->comment(PHP_EOL.Inspiring::quote().PHP_EOL); } } diff --git a/app/controllers/HomeController.php b/app/src/Http/Controllers/HomeController.php similarity index 92% rename from app/controllers/HomeController.php rename to app/src/Http/Controllers/HomeController.php index a1b5890f4..c634d2d90 100644 --- a/app/controllers/HomeController.php +++ b/app/src/Http/Controllers/HomeController.php @@ -1,6 +1,6 @@ ajax()) + { + return Response::make('Unauthorized', 401); + } + else + { + return Redirect::guest('login'); + } + } + } + +} \ No newline at end of file diff --git a/app/src/Http/Filters/BasicAuthFilter.php b/app/src/Http/Filters/BasicAuthFilter.php new file mode 100644 index 000000000..49316e2b3 --- /dev/null +++ b/app/src/Http/Filters/BasicAuthFilter.php @@ -0,0 +1,15 @@ +input('_token')) + { + throw new Illuminate\Session\TokenMismatchException; + } + } + +} \ No newline at end of file diff --git a/app/src/Http/Filters/GuestFilter.php b/app/src/Http/Filters/GuestFilter.php new file mode 100644 index 000000000..08cee12bb --- /dev/null +++ b/app/src/Http/Filters/GuestFilter.php @@ -0,0 +1,18 @@ +registerInspireCommand(); - - $this->commands('commands.inspire'); - } - - /** - * Register the Inspire Artisan command. - * - * @return void - */ - protected function registerInspireCommand() - { - // Each available Artisan command must be registered with the console so - // that it is available to be called. We'll register every command so - // the console gets access to each of the command object instances. - $this->app->bindShared('commands.inspire', function() - { - return new InspireCommand; - }); + $this->commands('InspireCommand'); } } \ No newline at end of file diff --git a/app/src/Providers/ErrorServiceProvider.php b/app/src/Providers/ErrorServiceProvider.php index af5464e4b..9ed406127 100644 --- a/app/src/Providers/ErrorServiceProvider.php +++ b/app/src/Providers/ErrorServiceProvider.php @@ -1,4 +1,4 @@ -setupErrorHandlers(); + // Here you may handle any errors that occur in your application, including + // logging them or displaying custom views for specific errors. You may + // even register several error handlers to handle different types of + // exceptions. If nothing is returned, the default error view is + // shown, which includes a detailed stack trace during debug. + + $this->app->error(function(\Exception $exception, $code) + { + $this->app['log']->error($exception); + }); } /** @@ -24,23 +33,4 @@ class ErrorServiceProvider extends ServiceProvider { // } - /** - * Setup the error handlers for the application. - * - * @return void - */ - protected function setupErrorHandlers() - { - // Here you may handle any errors that occur in your application, including - // logging them or displaying custom views for specific errors. You may - // even register several error handlers to handle different types of - // exceptions. If nothing is returned, the default error view is - // shown, which includes a detailed stack trace during debug. - - $this->app->error(function(Exception $exception, $code) - { - Log::error($exception); - }); - } - } \ No newline at end of file diff --git a/app/src/Providers/FilterServiceProvider.php b/app/src/Providers/FilterServiceProvider.php new file mode 100644 index 000000000..be0d7d8c7 --- /dev/null +++ b/app/src/Providers/FilterServiceProvider.php @@ -0,0 +1,37 @@ + 'AuthFilter', + 'auth.basic' => 'BasicAuthFilter', + 'csrf' => 'CsrfFilter', + 'guest' => 'GuestFilter', + ]; + +} \ No newline at end of file diff --git a/app/src/Providers/LogServiceProvider.php b/app/src/Providers/LogServiceProvider.php index 3a0666a34..c9af5d7e1 100644 --- a/app/src/Providers/LogServiceProvider.php +++ b/app/src/Providers/LogServiceProvider.php @@ -1,4 +1,4 @@ -setupLogging(); + // Here we will configure the error logger setup for the application which + // is built on top of the wonderful Monolog library. By default we will + // build a basic log file setup which creates a single file for logs. + + $this->app['log']->useFiles( + storage_path().'/logs/laravel.log' + ); } /** @@ -24,18 +30,4 @@ class LogServiceProvider extends ServiceProvider { // } - /** - * Setup the logging facilities for the application. - * - * @return void - */ - protected function setupLogging() - { - // Here we will configure the error logger setup for the application which - // is built on top of the wonderful Monolog library. By default we will - // build a basic log file setup which creates a single file for logs. - - Log::useFiles(storage_path().'/logs/laravel.log'); - } - } \ No newline at end of file diff --git a/app/src/Providers/RouteServiceProvider.php b/app/src/Providers/RouteServiceProvider.php new file mode 100644 index 000000000..b76e26dfa --- /dev/null +++ b/app/src/Providers/RouteServiceProvider.php @@ -0,0 +1,29 @@ +get('/', 'HomeController@index'); + } + +} \ No newline at end of file diff --git a/app/src/Requests/.gitkeep b/app/src/Requests/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/bootstrap/paths.php b/bootstrap/paths.php index 278898757..615713df8 100644 --- a/bootstrap/paths.php +++ b/bootstrap/paths.php @@ -54,4 +54,20 @@ return array( 'storage' => __DIR__.'/../storage', + /* + |-------------------------------------------------------------------------- + | Generator Paths + |-------------------------------------------------------------------------- + | + | These paths are used by the various class generators and other pieces + | of the framework that need to determine where to store these types + | of classes. Of course, they may be changed to any path you wish. + | + */ + + 'commands' => __DIR__.'/../app/src/Console', + 'controllers' => __DIR__.'/../app/src/Http/Controllers', + 'filters' => __DIR__.'/../app/src/Http/Filters', + 'requests' => __DIR__.'/../app/src/Http/Requests', + ); diff --git a/composer.json b/composer.json index b5d07e72c..57f80ae7a 100644 --- a/composer.json +++ b/composer.json @@ -4,17 +4,18 @@ "keywords": ["framework", "laravel"], "license": "MIT", "require": { - "laravel/framework": "4.3.*" + "laravel/framework": "4.3.*", + "andrewsville/php-token-reflection": "~1.4" }, "autoload": { "classmap": [ - "app/commands", - "app/controllers", - "app/database/migrations", - "app/database/seeds", + "app/database", "app/src", "app/tests/TestCase.php" - ] + ], + "psr-4": { + "App\\": "app/src/App/" + } }, "scripts": { "post-install-cmd": [ diff --git a/public/index.php b/public/index.php index f08822d95..6da55083d 100644 --- a/public/index.php +++ b/public/index.php @@ -45,5 +45,4 @@ $app = require_once __DIR__.'/../bootstrap/start.php'; | and wonderful application we have whipped up for them. | */ - $app->run();