Yii tutorial beginning

I learned yii 1 a week ago from official documentation.

Now I am aware of c classes and application ,modules, components and gui to create controller, models and views.

I learned how to generate model and controllers from gui tool.

But where can I start to code actually for my web app

Where do I place the code files.

I am new to programming but I haven’t practiced yet, so suggest me where can I practice yii each step to make a web app , better a complex one.

/* moved */

You are in luck, because Yii follows the MVC pattern (inspired by Ruby On Rails), where everything has it’s specific place.

You need to read the Guide, and read it good, especially this: Guide - Application Structure

You can actually put things where you like to put them, just be aware of the namespace, for instance app/models corresponds to the models directory in your project root.

Take a good look at the basic application template - after you’ve generated it using Composer (as described in the guide) - you will get the idea pretty soon, I reckon!

The link goes to yii2

But I learnt yii1

Isn’t that differs when I code in real time for me with knowledge of yii1

Then why did you post your question in Yii 2 - Tutorials, etc. ?

OK, we have a problem: why are you learning Yii 1 ?

It is legacy, obsolete - Yii 2 is much, much nicer, and better in every way.

I am sorry new to yii framework and forum and i didnt notice it.

One of my friend suggested to go with yii 1 because yii 2 gets security release every month.

So when I make an app in yii 2 , I have to update the app whenever yii 2 gets security release which is monthly.

If I am wrong guide me through. :blink:

Start with Yii 2, please!

You don’t have to update each month, your friend is not quite right with regards to that.

I usually update my Yii 2 powered projects once every 6 months…

And, besides: when using Composer, updating Yii 2 is really not a big deal at all.

It is not a manual operation, you just run a Composer command to update Yii 2 / your application.

Try it!

You definitely don’t want to learn obsolete technology - your friend is wrong.

Alright thank you jacmoe, can you give me any free step by step tutorial for making yii2 web app like yii blog guide.

First, read the Guide ! It is really good - keep it open in your browser.

This tutorial at Tuts+ is great:

Tuts+ : How to Program With Yii2

And, then - if you prefer video tutorials (Connelly is awesome!):

David Connelly’s Yii 2 Video Tutorials

And, how do you upgrade?

Well, each release should have a corresponding ‘upgrade’ document, like this:


For example, to update to Yii 2.0.12, and only Yii:

composer require "yiisoft/yii2:~2.0.12" --update-with-dependencies

Be sure to read the whole upgrade doc, though.

One of the things that you are probably going to spend time getting used to is Composer and namespaces and how autoloading works (using namespaces).

PSR-4 is a good overview of how it works: http://www.php-fig.org/psr/psr-4/

For example, PSR-4 and Composer makes it easy to load/include/locate classes/stuff:

If we have a php file in the directory ‘helpers/common’ named ‘Test.php’, then we can use it in our own code:

use app\helpers\common\Test;

Provided that the code in Test.php follows the PSR-4.

This is really flexible!

Oh, great. This post should be pinned.

OK, pinned :)

Feel free to add to the pinned topic - it is currently incomplete!