config/routes.php use Cake\Core\Plugin;
use Cake\Routing\RouteBuilder;
use Cake\Routing\Router;
Router::defaultRouteClass('DashedRoute');
Router::scope('/', function (RouteBuilder $routes) {
$routes->connect('/users', ['controller' => 'Users', 'action' => 'index']);
$routes->fallbacks('DashedRoute');
});
Plugin::routes();
Create a
UsersController.php file at
src/Controller/UsersController.php . Copy the
following code in the controller file.
src/controller/UsersController.php namespace App\Controller;
use App\Controller\AppController;
use Cake\ORM\TableRegistry;
use Cake\Datasource\ConnectionManager;
class UsersController extends AppController{
15.
CakePHP ─ View a Record
CakePHP
38
public function index(){
$users = TableRegistry::get('users');
$query = $users->find();
$this->set('results',$query);
}
}
?>
Create a directory