컨트롤러
PSR4 규칙에 따라, 컨트롤러 클래스의 네임스페이스는 plugin\{플러그인 식별자}
로 시작합니다. 예를 들어
새로운 컨트롤러 파일 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');
}
}
http://127.0.0.1:8787/app/foo/foo
에 접근할 때, 페이지는 hello index
를 반환합니다.
http://127.0.0.1:8787/app/foo/foo/hello
에 접근할 때, 페이지는 hello webman
을 반환합니다.
URL 접근
응용 플러그인 URL 주소 경로는 모두 /app
로 시작하며, 그 뒤에 플러그인 식별자가 오고, 그 다음에 구체적인 컨트롤러와 메소드가 이어집니다.
예를 들어 plugin\foo\app\controller\UserController
의 URL 주소는 http://127.0.0.1:8787/app/foo/user
입니다.