I have prepared a controller as below.
class TasksController extends AppController
{
public function index()
{
$this->paginate = [
'contain' => ['Users'],
'conditions' => [
'Tasks.user_id' => $this->Auth->user('id'),
]
];
$tasks = $this->paginate($this->Tasks);
$this->set(compact('tasks'));
//$this->set('tasks', $this->paginate($this->Tasks));
$this->set('_serialize', ['tasks']);
}
}
and my AppController as below.
class AppController extends Controller
{
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent("Auth", [
'authorize' => 'Controller',
'authenticate' => [
'Form' => [
'fields' => [
'username' => 'email',
'password' => 'password'
]
]
],
'loginAction' => [
'controller' => 'Users',
'action' => 'login'
],
'unauthorizedRedirect' => $this->referer()
]);
$this->Auth->allow(['display']);
}
}
When I enter the following URL, "http://localhost/cake/tasks.json" I get the following error.
Error: Tasks.jsonController could not be found.
Error: Create the class Tasks.jsonController below in file: src/Controller/Tasks.jsonController.php
<?php
namespace App\Controller;
use App\Controller\AppController;
class Tasks.jsonController extends AppController
{
}
What is the problem here and how do I fix it without adding route or json view file. [I am using the CakePHP 3.0]
"http://localhost/cake/tasks