Yii MVC PHP Framework Hello World Content Tutorial

Yii MVC PHP Framework Hello World Content Tutorial

Yii MVC PHP Framework Hello World Content Tutorial

Yesterday, with Yii MVC PHP Framework Hello World Tutorial as shown below, it was a primer tutorial mainly concerned with the setup and installation of a Hello World scenario regarding …

Yii is an open source, object-oriented, component-based MVC PHP web application framework. Yii is pronounced as “Yee” or [ji:] and in Chinese it means “simple and evolutionary” and it can be acronym for “Yes It Is!”.

The MVC stands for Model View Controller … (from Wikipedia again) …

Model–view–controller (MVC) is a software architectural pattern mostly for implementing user interfaces.

… to refresh your mind take a look at , whereas today, we show some early steps with Yii use that use MVC (without the Model) to change the content, and therefore, the appearance of our local MAMP Apache web server’s Hello World website … and you’ll be pleased to know the word “Hello” makes an appearance … no, Lionel.

Along the way we use Apache .htaccess methods making use of mod_rewrite module, which we hope, if you are following this, you are using.

Again, we have to thank the incredible advice on great advice of How to Program with Yii2: Getting Started – Envato Tuts+ Code Tutorial to keep us on the straight and narrow.

So, what do we do today, after yesterday’s installing and configuration with Yii, regarding content?

  1. we change ~/Sites/hello/config/web.php (add into components array) …

    'urlManager' => [
    'showScriptName' => false,
    'enablePrettyUrl' => true
    ],
    … and add a new ~/Sites/hello/web/.htaccess (in the same directory as index.php (of the website)) …

    RewriteEngine on

    # If a directory or a file exists, use it directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # Otherwise forward it to index.php
    RewriteRule . index.php
    … via (advice of) Turning on Pretty URLs section of How to Program with Yii2: Getting Started – Envato Tuts+ Code Tutorial
  2. point your web browser at …
    HTTP://localhost:8888/hello/web/site/about
  3. we change ~/Sites/hello/controller/SiteController.php (add in the PHP public function RE: mvC) …

    public function actionSay($target = 'World') {
    return $this->render('say', ['target' => $target]);
    }
    … and add a new ~/Sites/hello/views/site/say.php (RE: mVc) …

    <?php
    use yii\helpers\Html;
    ?>
    <h1>Hello <?= Html::encode($target) ?></h1>
    <p>Welcome to your Yii 2 demonstration application.</p>
    … via (advice of) Building the Say Hello World! Action section of How to Program with Yii2: Getting Started – Envato Tuts+ Code Tutorial
  4. point your web browser at …
    HTTP://localhost:8888/hello/web/site/say?target=Tuts%20Readers

Here’s a slideshow of highlights of yesterday’s (setup and configuration and install) and today’s (content considerations for) a Hello World website created using the Yii 2 MVC PHP framework.


Previous Yii MVC PHP Framework Hello World Tutorial is shown below.

Yii MVC PHP Framework Hello World Primer Tutorial

Yii MVC PHP Framework Hello World Tutorial

Today’s tutorial is a Hello World tutorial for Yii, to quote Wikipedia

Yii is an open source, object-oriented, component-based MVC PHP web application framework. Yii is pronounced as “Yee” or [ji:] and in Chinese it means “simple and evolutionary” and it can be acronym for “Yes It Is!”.

The MVC stands for Model View Controller … (from Wikipedia again) …

Model–view–controller (MVC) is a software architectural pattern mostly for implementing user interfaces.

It makes a fair bit of difference what version you talk about with Yii, and we are talking about Yii 2 today.

You can get up and going with a Hello World level of Yii usage really quickly (especially with the great advice of How to Program with Yii2: Getting Started – Envato Tuts+ Code Tutorial … thanks), and we can say, basically that the major steps for us, integrating it with MAMP (Mac Apache local web server) and a Linux operating system involved …

  1. installing composer, a tool for dependency management in PHP, via …

    curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/bin
    composer global require "fxp/composer-asset-plugin:~1.1.1"
    composer require yiisoft/yii2
    sudo ln -s /usr/bin/composer.phar /usr/bin/composer

    … that can also be found on the GitHub source repository
  2. composer setup specific to Hello World project …

    cd ~/Sites
    composer global require "fxp/composer-asset-plugin:1.0.0-beta2"
    composer create-project --prefer-dist yiisoft/yii2-app-basic hello

    … in addition we found that we needed to …

    mkdir ~/Sites/hello/vendor/bower/bootstrap
    mkdir ~/Sites/hello/vendor/bower/bootstrap/dist
    mkdir ~/Sites/hello/vendor/bower/jquery
    mkdir ~/Sites/hello/vendor/bower/jquery/dist

  3. create software to help out MAMP via …

    cd /Applications/MAMP/htdocs
    ln -s ~/Sites/hello/ /Applications/MAMP/htdocs/hello

  4. point your web browser at …
    HTTP://localhost:8888/hello/web

You can do great organizational and fast and guaranteed and consistent PHP web work using Yii Framework. Just imagine a CRUD idea you have, and Yii could be a great option for you. Here’s a slideshow of highlights of today’s Hello World website create using the Yii 2 MVC PHP framework.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Tutorials and tagged , , , , , , , , , , , , , , , , , . Bookmark the permalink.

10 Responses to Yii MVC PHP Framework Hello World Content Tutorial

  1. Matt Smith says:

    It’s impressive that you are getting thoughts from this post as well as from our dialogue made here.

  2. There is noticeably a bundle to know about this. I suppose you might have created specific good points in functions also.

  3. Wendy Kelly says:

    I loved as much as you will receive carried out right here. The sketch is tasteful, your authored subject matter stylish. nonetheless, you command get bought an nervousness over that you wish be delivering the following. unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this increase.

  4. Amelia Carr says:

    It’s an amazing post designed for all the web people; they will get benefit from it I am sure.

  5. As with every E3, once the dust settles and the big three (Microsoft, Nintendo, and Sony) have said everything there is to say, the fanboys pull out their boxing gloves and begin the debate over which company actually “won” E2.A better care and service has varied email developed features to serve you every tread of the way.And you can trace much of that strategy back to a 2008 memo by San Francisco’s master of crisis communications, Sam Singer.my web site; modern war hack

  6. Andrew North says:

    There’s certainly a lot to know about this issue. I love all the points you have made.

  7. Wow, marvelous weblog format! How long have you been blogging for? you made running a blog glance easy. The overall glance of your site is excellent, as neatly as the content material!

  8. I’m amazed, I must say. Seldom do I come across a blog that’s both equally educative and amusing, and let me tell you, you’ve hit the nail on the head. The problem is something too few people are speaking intelligently about.

  9. Car Repairs says:

    Excellent read, I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch because I found it for him smile Therefore let me rephrase that: Thanks for lunch!

  10. Rocco Wayns says:

    I wish to get across my affection for your kind-heartedness in support of individuals that really need guidance on this important topic. Your real dedication to getting the message all around appeared to be certainly invaluable and has all the time allowed girls just like me to realize their aims. This interesting guideline can mean this much a person like me and a whole lot more to my colleagues. With thanks; from each one of us.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>