📜 ⬆️ ⬇️

Talk about Yii 2

Yii is probably the most popular PHP framework in the CIS.
For many years he was a wonderful tool and helped us earn bread and butter.
But is it worth starting new projects on it in 2017? I thought.


Framework architecture


Mentally back in 2014.
Waiting for the second version of Yii seems to be infinitely long; core developers do not name any deadlines.
Development is conducted in a repository closed to the public.


And SamDark presents Yii 2.0:


After three years of intensive development ...
As you may already know, Yii 2.0 has been rewritten from scratch.

It turns out that the architecture was laid in 2014 - 3 = 2011 year. Or earlier?


Take a look at Component.php from Yii 2
And now on CComponent.php from Yii 1
And now on TComponent.php from the PRADO Framework - the grandfather of the current Yii. Looks familiar.


The origins of the very same PRADO go somewhere in the heyday of Delphi:


The very original inspiration of the PRADO came from Apache Tapestry.
Qiang Xue borrowed many ideas from Borland Delphi and Microsoft ASP.NET during the design and implementation.
The first version of PRADO came out in June 2004 and was written in PHP 4.

From the first version we got global constants in the code , our own autoloader , our own cunning system of aliases for files and folders.


Oooooh. Just a reminder that now is the second half of 2017.


Yii , , .
Yii — , .
, Yii Object, __get, __set, __isset .


Component, Object, .


, , . . behaviors.
ActiveRecord 5 5 .
, "", "", , , , — .
image


, , … , PRADO Framework, "" TButton, TAccordion .


Yii . .
, , - $post->title = 'Hello'?
, , , , $post event- behavior-.


.


, Yii::$app. - .


DI-


Yii 2 .
compile-time , circular references, ( Symfony Laravel), Contextual Binding ( Laravel).
Yii::$container. .
Yii 2 , Yii::$app, .


: Qiang Yii 2 2011 , , 2.0.0-alpha 2.0.0-beta.


Active Record


Active Record vs Data Mapper, AR Yii .
API, . .


— - AR-, Yii.



.
Laravel Elixir, Symfony — Webpack encore.
Yii , .


Yii 2 fxp/composer-asset-plugin, , jQuery c composer-, , Yii.


jQuery Yii 2.


composer-, .
Yii composer install/update ,
.. composer - Bower-.
- composer- , - fxp/composer-asset-plugin.


composer-, npm bower . .


, Yii - — .



HTTP, , … , .
, Yii, PSR-.


Yii



, 2.0?
, 2.1? .


2.0.x: 222 — No due date.
2.1.0: 58 — No due date.
2.2.x: 1 — No due date.


.. 2.1 , 2.2 . , , .


, — Laravel Symfony — . LTS-. Yii 2.1 long-term support.



- Yii — Yii.
, , .


, PHP, , , Yii — Yii.
Yii , . .


, , framework-agnostic DI-, .
- , Yii- ActiveRecord
-.
, , .


- Yii, Yii , Object Component. .
, .
DDD CQRS/Event Sourcing Yii . , .


. VarDumper , Symfony.
— . .


, .
. . . . .


-, - Yii .
Yii API, , Yii.


.


PHP 7


Yii 2 PHP 7+.
type-hinting-, core- .
, :


//        "42"
SomeModel::findOne(42);

//   
SomeModel::findOne(['id' => 42]);

//    ,   PK -     
SomeModel::findOne([1, 2, 3]);

//   
Url::to(['site/index']);

//  
Url::to('images/logo.gif');

//  
$relativeBaseUrl = Url::base();
$absoluteBaseUrl = Url::base(true);
$httpsAbsoluteBaseUrl = Url::base('https');

. - , - API .
, API .


Qiang


Yii , , Qiang Xue ?
, .


.
, .



Yii — — .
-, . , , Yii.
Yii . , , .


, .
- .


, . -, -, , gitter-.


, Yii ;)


')

Source: https://habr.com/ru/post/333398/


All Articles