HTTP控制器

2017-07-30  本文已影响0人  禾线子

Route还有这么一种用法,隐式控制器。

Route::controller('users', 'UserController');

namespace App\Http\Controllers;

class UserController extends Controller
{
    /**
     * 响应 GET /users 请求
     */
    public function getIndex()
    {
        //
    }

    /**
     * 响应 GET /users/show/1 请求
     */
    public function getShow($id)
    {
        //
    }

    /**
     * 响应 GET /users/admin-profile 请求
     */
    public function getAdminProfile()
    {
        //
    }

    /**
     * 响应 POST /users/profile 请求
     */
    public function postProfile()
    {
        //
    }
}

同时,还有一个路由缓存,可以提高访问速度。

php artisan route:cache
php artisan route:clear
上一篇 下一篇

猜你喜欢

热点阅读