Commit 6070d93c authored by Taylor Otwell's avatar Taylor Otwell

Working on new directory structure.

parent 8aa4a0a6
......@@ -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',
),
......
......@@ -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,
),
);
<?php
class BaseController extends Controller {
/**
* Setup the layout used by the controller.
*
* @return void
*/
protected function setupLayout()
{
if ( ! is_null($this->layout))
{
$this->layout = View::make($this->layout);
}
}
}
<?php
/*
|--------------------------------------------------------------------------
| Application & Route Filters
|--------------------------------------------------------------------------
|
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
App::before(function($request)
{
if (App::isDownForMaintenance())
{
return Response::make('Be right back!');
}
});
App::after(function($request, $response)
{
//
});
/*
|--------------------------------------------------------------------------
| Authentication Filters
|--------------------------------------------------------------------------
|
| The following filters are used to verify that the user of the current
| session is logged into this application. The "basic" filter easily
| integrates HTTP Basic authentication for quick, simple checking.
|
*/
Route::filter('auth', function()
{
if (Auth::guest())
{
if (Request::ajax())
{
return Response::make('Unauthorized', 401);
}
else
{
return Redirect::guest('login');
}
}
});
Route::filter('auth.basic', function()
{
return Auth::basic();
});
/*
|--------------------------------------------------------------------------
| Guest Filter
|--------------------------------------------------------------------------
|
| The "guest" filter is the counterpart of the authentication filters as
| it simply checks that the current user is not logged in. A redirect
| response will be issued if they are, which you may freely change.
|
*/
Route::filter('guest', function()
{
if (Auth::check()) return Redirect::to('/');
});
/*
|--------------------------------------------------------------------------
| CSRF Protection Filter
|--------------------------------------------------------------------------
|
| The CSRF filter is responsible for protecting your application against
| cross-site request forgery attacks. If this special token in a user
| session does not match the one given in this request, we'll bail.
|
*/
Route::filter('csrf', function()
{
if (Session::token() != Input::get('_token'))
{
throw new Illuminate\Session\TokenMismatchException;
}
});
<?php
/*
|--------------------------------------------------------------------------
| Require The Filters File
|--------------------------------------------------------------------------
|
| Next we will load the filters file for the application. This gives us
| a nice separate location to store our route and application filter
| definitions instead of putting them all in the main routes file.
|
*/
require __DIR__.'/filters.php';
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| then declare the method to execute when that URI is requested.
|
*/
Route::get('/', 'HomeController@index');
<?php
<?php namespace App;
use Eloquent;
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
......@@ -21,6 +22,6 @@ class User extends Eloquent implements UserInterface, RemindableInterface {
*
* @var array
*/
protected $hidden = array('password', 'remember_token');
protected $hidden = ['password', 'remember_token'];
}
......@@ -19,7 +19,7 @@ class InspireCommand extends Command {
*
* @var string
*/
protected $description = 'Display an inpiring quote.';
protected $description = 'Display an inpiring quote';
/**
* Create a new command instance.
......@@ -38,7 +38,7 @@ class InspireCommand extends Command {
*/
public function fire()
{
$this->info(Inspiring::quote());
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}
}
<?php
class HomeController extends BaseController {
class HomeController extends Controller {
/*
|--------------------------------------------------------------------------
......
<?php
use Illuminate\Http\Request;
class AuthFilter {
/**
* Run the request filter.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function filter(Request $request)
{
if (Auth::guest())
{
if ($request->ajax())
{
return Response::make('Unauthorized', 401);
}
else
{
return Redirect::guest('login');
}
}
}
}
\ No newline at end of file
<?php
class BasicAuthFilter {
/**
* Run the request filter.
*
* @return mixed
*/
public function filter()
{
return Auth::basic();
}
}
\ No newline at end of file
<?php
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
class CsrfFilter {
/**
* Run the request filter.
*
* @return mixed
*/
public function filter(Route $route, Request $request)
{
if (Session::token() != $request->input('_token'))
{
throw new Illuminate\Session\TokenMismatchException;
}
}
}
\ No newline at end of file
<?php
class GuestFilter {
/**
* Run the request filter.
*
* @return mixed
*/
public function filter()
{
if (Auth::check())
{
return Redirect::to('/');
}
}
}
\ No newline at end of file
<?php
class MaintenanceFilter {
/**
* Run the request filter.
*
* @return mixed
*/
public function filter()
{
if (App::isDownForMaintenance())
{
return Response::make('Be right back!');
}
}
}
\ No newline at end of file
<?php
<?php namespace Providers;
use Illuminate\Support\ServiceProvider;
......
<?php
<?php namespace Providers;
use InspireCommand;
use Illuminate\Support\ServiceProvider;
class ArtisanServiceProvider extends ServiceProvider {
......@@ -21,25 +22,7 @@ class ArtisanServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->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
<?php
<?php namespace Providers;
use Illuminate\Support\ServiceProvider;
......@@ -11,7 +11,16 @@ class ErrorServiceProvider extends ServiceProvider {
*/
public function boot()
{
$this->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
<?php namespace Providers;
use Illuminate\Routing\FilterServiceProvider as ServiceProvider;
class FilterServiceProvider extends ServiceProvider {
/**
* The filters that should run before all requests.
*
* @var array
*/
protected $before = [
'MaintenanceFilter',
];
/**
* The filters that should run after all requests.
*
* @var array
*/
protected $after = [
//
];
/**
* All available route filters.
*
* @var array
*/
protected $filters = [
'auth' => 'AuthFilter',
'auth.basic' => 'BasicAuthFilter',
'csrf' => 'CsrfFilter',
'guest' => 'GuestFilter',
];
}
\ No newline at end of file
<?php
<?php namespace Providers;
use Illuminate\Support\ServiceProvider;
......@@ -11,7 +11,13 @@ class LogServiceProvider extends ServiceProvider {
*/
public function boot()
{
$this->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
<?php namespace Providers;
use Illuminate\Routing\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider {
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*
* @return void
*/
public function before()
{
//
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->get('/', 'HomeController@index');
}
}
\ No newline at end of file
......@@ -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',
);
......@@ -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": [
......
......@@ -45,5 +45,4 @@ $app = require_once __DIR__.'/../bootstrap/start.php';
| and wonderful application we have whipped up for them.
|
*/
$app->run();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment