mirror of
https://github.com/laravel/laravel.git
synced 2025-02-20 11:53:14 +08:00
Working on overall app structure.
This commit is contained in:
parent
a5001352e6
commit
0e0fd73b43
43
app/commands/InspireCommand.php
Normal file
43
app/commands/InspireCommand.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class InspireCommand extends Command {
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'inspire';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Display an inpiring quote..';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$this->comment('Inspiring Quote Here.');
|
||||
}
|
||||
|
||||
}
|
@ -95,6 +95,11 @@ return array(
|
||||
|
||||
'providers' => array(
|
||||
|
||||
'AppServiceProvider',
|
||||
'ArtisanServiceProvider',
|
||||
'ErrorServiceProvider',
|
||||
'LogServiceProvider',
|
||||
|
||||
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
|
||||
'Illuminate\Auth\AuthServiceProvider',
|
||||
'Illuminate\Cache\CacheServiceProvider',
|
||||
|
@ -13,7 +13,10 @@
|
||||
|
||||
App::before(function($request)
|
||||
{
|
||||
//
|
||||
if (App::isDownForMaintenance())
|
||||
{
|
||||
return Response::make('Be right back!');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,5 +1,18 @@
|
||||
<?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
|
27
app/src/Providers/AppServiceProvider.php
Normal file
27
app/src/Providers/AppServiceProvider.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Bootstrap the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
}
|
45
app/src/Providers/ArtisanServiceProvider.php
Normal file
45
app/src/Providers/ArtisanServiceProvider.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ArtisanServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Bootstrap the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
46
app/src/Providers/ErrorServiceProvider.php
Normal file
46
app/src/Providers/ErrorServiceProvider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ErrorServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Bootstrap the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->setupErrorHandlers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
41
app/src/Providers/LogServiceProvider.php
Normal file
41
app/src/Providers/LogServiceProvider.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class LogServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Bootstrap the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->setupLogging();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Artisan Commands
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| 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.
|
||||
|
|
||||
*/
|
||||
|
@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Laravel Class Loader
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| In addition to using Composer, you may use the Laravel class loader to
|
||||
| load your controllers and models. This is useful for keeping all of
|
||||
| your classes in the "global" namespace without Composer updating.
|
||||
|
|
||||
*/
|
||||
|
||||
ClassLoader::addDirectories(array(
|
||||
|
||||
app_path().'/console',
|
||||
app_path().'/controllers',
|
||||
app_path().'/models',
|
||||
app_path().'/database/seeds',
|
||||
|
||||
));
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Error Logger
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| 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');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Error Handler
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| 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.
|
||||
|
|
||||
*/
|
||||
|
||||
App::error(function(Exception $exception, $code)
|
||||
{
|
||||
Log::error($exception);
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Handler
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The "down" Artisan command gives you the ability to put an application
|
||||
| into maintenance mode. Here, you will define what is displayed back
|
||||
| to the user if maintenance mode is in effect for the application.
|
||||
|
|
||||
*/
|
||||
|
||||
App::down(function()
|
||||
{
|
||||
return Response::make("Be right back!", 503);
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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 app_path().'/filters.php';
|
@ -1,3 +0,0 @@
|
||||
<?php
|
||||
|
||||
//
|
@ -32,19 +32,6 @@ if (file_exists($compiled = __DIR__.'/compiled.php'))
|
||||
require $compiled;
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Setup Patchwork UTF-8 Handling
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The Patchwork library provides solid handling of UTF-8 strings as well
|
||||
| as provides replacements for all mb_* and iconv type functions that
|
||||
| are not available by default in PHP. We'll setup this stuff here.
|
||||
|
|
||||
*/
|
||||
|
||||
Patchwork\Utf8\Bootup::initMbstring();
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Laravel Auto Loader
|
||||
|
@ -8,11 +8,11 @@
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"app/console",
|
||||
"app/commands",
|
||||
"app/controllers",
|
||||
"app/models",
|
||||
"app/database/migrations",
|
||||
"app/database/seeds",
|
||||
"app/src",
|
||||
"app/tests/TestCase.php"
|
||||
]
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user