我将所有过滤器都放在一个名为filters的单独目录中。这就是我的 filters.php 文件的样子......
//---------------------------------------------------------
// Route Filters
//---------------------------------------------------------
Route::filter('auth', 'AuthFilter@default');
Route::filter('auth.basic', 'AuthFilter@basic');
Route::filter('guest', 'AuthFilter@guest');
Route::filter('csrf', 'CsrfFilter');
我通过composer.json自动加载它们
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/filters",
"app/presenters",
"app/repositories",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
更新 composer.json 文件后,您需要运行命令
composer dump-autoload
要验证您的文件是否会被加载,请查看
vendor/composer/autoload_classmap.php