创建新的控制器
namespace App\Controller;
class PostsController extends AppController {
public function initialize(){
parent::initialize();
// code that you want to run before every action
}
public function view($id) {
//Your code here
}
}