Create controller, model and view CAKEPHP 3 -


i've started use cakephp have lot of doubts.

first of all:

when create controller, model , view db conection with:

cake bake "name"  

it works fine when need no db 1 part of webpage can't because don't work.

so delete files:

/src/controller/mycontroller.php /src/model/entity/model.php /src/model/table/mytable.php /src/template/mytemplate/* /tests/testcase/* 

and add following line in routes.php

$routes->connect('/', ['controller' => 'pages', 'action' => 'display', 'inicio']); 

this works, when can't see layout in page

i have conection bootstrap , header , footer in layout don't work, , don't have controller code in.

how can controller model , view without db?

thanks

and add following line in routes.php

$routes->connect('/', ['controller' => 'pages', 'action' => 'display', 'inicio']);

this works, when can't see layout in page

create empty inicio.ctp , don't use $this->layout = false;

how can controller model , view without db?

bake new controller command cake bake controller home or controller name.

inside generated controller use empty methods, without calling models / orm methods, or set variables, like

public function index() {  // empty method }  public function aboutus() {  $about_us = [    'title' => 'my title here',    'description' => 'some text..'  ];  $this->set(compact('about_us')); }  public function contact() {  // add modelless form here } 

modelless forms: http://book.cakephp.org/3.0/en/core-libraries/form.html

note: can add these methods @ pagescontroller , route, example:

$routes->connect('/contact', ['controller' => 'pages', 'action' => 'contact']); 

Comments