Yii Framework Introduction and Hello World Tutorial

Yii Framework Introduction and Hello World Tutorial

Today, We want to share with you Yii Framework Introduction and Hello World Tutorial.
In this post we will show you Yii Framework Introduction and hello world example, hear for Yii First Hello World Tutorial we will give you demo and example for implement.
In this post, we will learn about Simple Yii Hello World Example Application with an example.

Basic Steps for some Yii framework

  • Prerequisities
  • Creating an Action
  • Creating a View
  • Trying it Out

Simple Prerequisities for Yii Framework using PHP

-PHP and databases (DB)
-SQL query
-simple web using PHP, HTML, CSS and DB.
-important is OOP (Object oriented programming)
Like as
+ actionSay classes
+ overriding functions
+ using constructor
+ public and private methods
+ Some propertie

Also Read :  vuejs pass multiple parameters to $http post

Download the Yii Framework

Download

The directory structure of the Yii project site | Yii PHP Framework

 
 /
    backend/
    common/
        components/
        config/
            params.php
            params-local.php *
        lib/
            Pear/
            yii/
            Zend/
        migrations/
        models/
            Comment.php
            Extension.php
            ...some files
    console/
        commands/
            SitemapCommand.php
            ...some files
        config/
            main.php
            main-local.php *
            params.php
            params-local.php *
        runtime/
        yiic.php *
    frontend/
        components/
        config/
            main.php
            main-local.php *
            params.php
            params-local.php *
        controllers/
            SiteController.php
            ...some files
        lib/
        models/ 
            ContactForm.php
            SearchForm.php      
        runtime/
        views/
            layouts/
            site/
        www/
            assets/
            css/
            js/
            index.php *
    yiic
    yiic.bat
 

Yii framework : Creating an Action

controllers/SiteController.php

<?php
namespace app\controllers;
use yii\web\Controller;
class SiteController extends Controller
{
    // ...here is existing code some...

    public function actionSay($message = 'Hello - world in pakainfo.com')
    {
        return $this->render('say', ['message' => $message]);
    }
}

Simple Creating a View

<?php
use yii\helpers\Html;
?>
<?= Html::encode($message) ?>

Also Read :  DataTables Pagination Server-side Processing using PHP and MySQL

Simple Trying it Out

http://yourhostname/index.php?r=site%2Fsay&message=Hello+World

Some Important Points for Yii framework

The Controllers should −

  • In controller,Be very thin.
  • In controller,Each action should contain only most a few lines of code useful.
  • In controller,Use Views for all responses data.
  • In controller,Not embed HTML.
  • In controller,Access the request data.
  • In controller,Call methods of used of models.
  • In controller,Not process the request some data.
  • In controller,These should be every processed in the model.

We hope you get an idea about Yii Hello World Application
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page for Yii First Example Program.

Also Read :  Vuejs Dynamic Dropdown Select Menu using json

We hope This Post can help you…….Good Luck!.

Leave a Reply

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