It’s been so long time since I wrote the last article about Yii framework.

I has took about 2 months to look over the new Yii framework 2.0 since the beta from 28th of September. It really surprised me, it completely change the whole structure of the old version.  You don’t have to install the modules, plugins, copy paste, change the config file…Forget it, this is ancient. Everything now are working the composer, namespace, autoload…

If you are a newcomer, it’s easy for you to start something new and if you are already a Yii developer, it’s great.

And me myself, I think I need to learn a tons of thing before working with the new Yii framework 2.0

What do I need to know before starting the Yii framework 2.0 ?

1. PHP 5.4: Namespace and Array.

Why is namespace ? Since the most obvious change in Yii 2.0 is the use of namespaces , so I think I must know what it is ?
Let’s imagine, in PHP 5.3 or the old PHP, we cannot create two classes with the same name. They have to be unique . The issue is if we use a third-party library which has the class name User , of course you cannot use the class User in your model anymore. What’s a shame with this situation ! We need to remove the library, find the one or change our model User class name for sure.

This namespace allow us to circumvent this issue, in face we can have as many user class as we like. That’s cool.

About the array, the old array

$config = array('something'=>'else','db'=>array('host'=>'localhost'));

now become

$config = ['something'=>'else','db'=>['host'=>'localhost']];

Trust me, it’s going to me while before I can read that as quickly as I can the old style.

2. Composer – PHP package manager

What is composer and packagist ?

In the most simple concept, composer is the command-line utility with which you install packages.  It contains a dependency solver to be able to recursively resolve inter-package dependencies, a set of downloaders, installers and other fancy things.

Ultimately as a user, all you have to do is drop a composer.json file in your project and run composer.phar install . This composer.json file defines your project dependencies, and optionally configures composer (more on that later). Here is a minimal example to require one library:


Packagist is the default package repository. We can submit our packages to it, and it will build new packages automatically whenever we create a tag or update a branch in your VCS repository.. You may have noticed in the composer.json above that there was no version, and that is because Packagist takes care of it, it creates (and updates) a master-dev version for GitHub repo’s master branch, and then creates new versions.

3. Codeception testing framework.

The codeception is a way to testing your code. Codeception uses PHPUnit as a backend for running tests. And any PHPUnit test can be added to Codeception test suite then execute. I haven’t look deeply into it but somehow, it’s necessary for whom run the testcase on a big yii project.

4. Bootstrap 3.

The front-end design now is not a big trouble anymore. It’s so good to be know that the new yii framework has integrated with the lasted twitter bootstrap. I don’t need to include any css link, just call the classes and the yii library will do it for me. Bootstrap 3 is a big update for the css, bootstrap 3 is designed not just be mobile responsive but mobile first. It’s well worth it.

I will spend more time go deeply in each technology of the new yii framework 2.0 and maybe blogging some things.  But trust me this new yii framework is so awesome.