Bộ điều khiển
Theo tiêu chuẩn PSR4, không gian tên của lớp bộ điều khiển bắt đầu bằng plugin\{định danh plugin}. Ví dụ:
Tạo tệp bộ điều khiển mới plugin/foo/app/controller/FooController.php.
<?php
namespace plugin\foo\app\controller;
use support\Request;
class FooController
{
public function index(Request $request)
{
return response('hello index');
}
public function hello(Request $request)
{
return response('hello webman');
}
}
Khi truy cập http://127.0.0.1:8787/app/foo/foo, trang sẽ trả về hello index.
Khi truy cập http://127.0.0.1:8787/app/foo/foo/hello, trang sẽ trả về hello webman.
Truy cập url
Đường dẫn url của ứng dụng plugin đều bắt đầu bằng /app, tiếp theo là định danh plugin, sau đó là bộ điều khiển và phương thức cụ thể.
Ví dụ, đường dẫn url của plugin\foo\app\controller\UserController là http://127.0.0.1:8787/app/foo/user