3. What’s New Yii-2
⦿ Composer
⦿ PSR Compliance. Autoloading
⦿ PHP 5.4 or above
▪ Namespaces.
▪ Anonymous functions.
▪ Short array syntax.
▪ Short echo tags <?= are used in view files.
▪ SPL classes and interfaces.
▪ Late Static Bindings.
▪ Date and Time.
▪ Traits.
▪ intl.
8. Yii vs Other Frameworks?
• MVC (Model-View-Controller)
• Design pattern
• Full-stack framework with ready-to-use features:
query builders and ActiveRecord for both relational and NoSQL databases;
RESTful API development support;
multi-tier caching support;
and more.
• Extremely extensible.
• High performance is always a primary goal of Yii.
• Backed up by a strong core developer team, as well as a large community of
professionals constantly contributing to Yii's development.
13. Path Alias
⦿ Must use @
⦿ @yii means Yii installation directory
⦿ Closely related to class namespaces
14. View Class
⦿ $this in a view no longer means controller or
widget object
⦿ Smarty and Twig support added
⦿ Prado support removed
15. Models
⦿ formName() returns the form name (previously
hardcoded)
⦿ Load() and loadMultiple() added to aid data
population
⦿ New method: scenarios() to define which fields
need to be validated
⦿ Safe validators discontinued, scenarios() define
which are safe
16. Controllers
⦿ Render() and renderPartial() return content
instead of sending it out
⦿ One must echo contents now
17. Widgets
⦿ Simplified process
⦿ Use begin(), end() and widget() instead of
passing strings through beginWidget() and
endWidget().
18. Themes
⦿ CThemeManager is gone
⦿ Path maps
⦿ ['/web/views' => '/web/themes/basic’]
⦿ /web/views/site/index.php will be
/web/themes/basic/site/index.php
⦿ Any view file can have a theme, even if
rendered outside of the context of a controller