Displaying static pages
If you have a few static pages and aren't going to change them very frequently, then it's not worth querying the database and implementing page management for them.
Getting ready
Create a new application using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-startinstallation.html.
How to do it…
Create the test controller file,
@app/controllers/TestController.php
, as follows:<?php namespace app\controllers; use yii\web\Controller; class TestController extends Controller { public function actions() { return [ 'page' => [ 'class' => 'yii\web\ViewAction', ] ]; } }
Now, put your pages into
views/test/pages
, and name themindex.php
andcontact.php
. The content ofindex.php
is as follows:<h1>Index</h1> content of index file Contact.php content is: <h2>Contacts</h2> <p>Our contact: contact@localhost</p...