Yii 2.0 framework description (marketing alert!)

The “Yii - we don’t force you” would be good if it were true, but actually one of the things I’ve read people dislike about Yii is that it does force coders into a certain way, as discussed in this Laravel forum thread:

I think Yii slogan needs to re-emphasize the high-performance claim (which has been stolen by Fabien Potencier for Symfony 2, even though it is a very slow framework) and appeal to coders who dislike “enterprise” frameworks that embrace complexity to feed their consulting business (hello ZF and SF2). Here’s my suggestion:

"Yii is a high-performance component-based PHP framework best for practical developers to build high traffic web applications."

Note the “practical developer” reference, I picked that up from SamDark’s Yii2 presentations.

Regards

Hi Webspeed,

thanks for your posting. I am looking from time to time for negative reviews about Yii, just to think out of the box. But they’re hard to find, so I really appreciate it. :)

I’d say “First” and “Second” are just plain wrong. You can (easily) add the functionality to gii and there are several templating engines supported in Yii.

Can’t say much about “Third” and about “Fourth” … let’s see what Yii2 brings.

Best regards,

Schmunk

Both Yii and Yii2 suply the foundation for IoC: behaviors.

They also supply the foundation for DI: Yii::createObject.

Yii2 almost supports DI: Yii::$objectConfig as the metadata configuration and Yii::createObject as the dependency manager. Only properties that need to be initialized with a unique instance of a class are not supported.

What Yii needs to support true IoC is a ‘manager’ (IoC manager). This manager would need a configuration array to list, per class, all behaviors that need to be attached to the class.

Example:

Yii::$objectDependencies = array(

…‘yii\Controller’ => array(

[size=“2”]…‘interface1’ => ‘MyControllerBehavior’,[/size]

[size=“2”]…‘interface2’ => ‘YourControllerBehavior’, [/size]

[size="2"]…),[/size]

[size="2"]);[/size]

class \yii\Component

{

…function __construct(…)

…{

… …

…$di = [size="2"]Yii::$objectDependencies[get_class()];[/size]

[size="2"]…// optionally check for missing interface declarations and fill these with default behaviors, although this is probably not really necessairy for true IoC.[/size]

…attachBehaviors($di[size="2"]);[/size]

… …

…}

}

Or maybe there could be a separate function, similar to or integrated in Yii::createObject.

I hope this can serve as a basis for your thoughts on IoC within Yii.