CakePHP3:最初の手順 覚え書き
CakePHP3をインストール後から・・・
・XxxxsController.phpの作成 src/ControllerにXxxxsController.phpを作成。
※ まあこんな感じで・・・ --- XxxxsController.php --- <?php namespace App\Controller ; use App\Controller\AppController ; class XxxxsController extends AppController { public function index(){ } }
・ctpファイルを作成 上記のままだとindex.ctpファイルが無い、作れ!とエラーがでるのでsrc/TemplateにXxxxsというディレクトを作成して、その中にindex.ctpを作成する。
※ たとえばこんな感じ。HTMLファイルだと思って適当に何か表示するものを書く。 --- index.ctp --- <h1>ここに書く</h1>
webroot/css/xxxxs.css webroot/js/xxxxs.js (まずは中身は空でいい) を作成して、 src/Template/Layout/notes.ctp を作成する。
※ まずはこんな感じ --- xxxxs.ctp --- <!DOCTYPE html> <html> <head> <?=$this->Html->charset() ?> <title><?=$this->fetch('title') ?></title> <?=$this->Html->css('notes') ?> <?=$this->Html->script('notes') ?> </head> <body> <header class="head row"> <!-- <?=$this->element('header',$header) ?> --> </header> <div class="content row"> <?=$this->fetch('content') ?> </div> <footer class="foot row"> <!-- <?=$this->element('footer',$footer) ?> --> </footer> </body> </html>