美文网首页
HTTP控制器

HTTP控制器

作者: 禾线子 | 来源:发表于2017-07-30 11:42 被阅读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

相关文章

网友评论

      本文标题:HTTP控制器

      本文链接:https://www.haomeiwen.com/subject/rauhlxtx.html