cakephp中的命名空间错误

时间:2016-03-01 05:45:02

标签: php cakephp-3.0

this is a sample page from files of my app

namespace cake \ Controller;

使用cake \ Controller \ AppController;

这两行在Dreamweaver中显示为红色

1 个答案:

答案 0 :(得分:1)

在cakephp中,所有控制器都在命名空间App\Controller中并使用App\Controller\AppController,因为AppController是默认值,所有其他控制器都扩展它。

namespace App\Controller;

use App\Controller\AppController;

/**
 * Users Controller
 *
 * @property \App\Model\Table\UsersTable $Users
 */
class UsersController extends AppController
{

    /**
     * Index method
     *
     * @return \Cake\Network\Response|null
     */
    public function index()
    {
        $users = $this->paginate($this->Users);

        $this->set(compact('users'));
        $this->set('_serialize', ['users']);
    }
}