Peter J. Kambey – Yii Enthusiasm
HIGH PERFORMANCE
&
BEST FEATURES YII-2
About Me
http://about.me/peterjkambey
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.
A. Non Yii Users / New
Comers
http://www.yiiframework.com/doc-2.0/guide-index.html
What is Yii
What is Yii Best for?
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.
Personal Opinion
B. Yii Users
Namespaces
⦿ Prefixes no longer used
⦿ Based on directory structure
e.g. yiiwebRequest
Events
⦿ onEvent method definition no longer
needed
⦿ $component->on($eventName,
$handler);
Path Alias
⦿ Must use @
⦿ @yii means Yii installation directory
⦿ Closely related to class namespaces
View Class
⦿ $this in a view no longer means controller or
widget object
⦿ Smarty and Twig support added
⦿ Prado support removed
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
Controllers
⦿ Render() and renderPartial() return content
instead of sending it out
⦿ One must echo contents now
Widgets
⦿ Simplified process
⦿ Use begin(), end() and widget() instead of
passing strings through beginWidget() and
endWidget().
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
Console applications
⦿ Controllers
⦿ Console and web controllers have same
base class
⦿ Console controller is similar to
CConsoleCommand
Internationalisation (i18n)
⦿ Date and number formatter are out
⦿ PECL intl php module is in
⦿ I18n application component
ActiveForm
⦿ Field: label, input, error message and
hint text
Query Builder
⦿ CDbCommand, CDbCriteria,
CDbCommandBuilder
⦿ yiidbQuery|Query = DB
⦿ yiidbQueryBuilder|QueryBuilder =
Query
Active Record
⦿ yiidbActiveRecord|ActiveRecord
⦿ Relational AR Query
⦿ 1.1 = relations()
⦿ 2.0 = getter methods
Active Record
⦿ No longer uses model(), but uses the
find method:
User and IdentityInterface
⦿ CWebuser is now yiiwebUser
⦿ CUserIdentity is no more
⦿ yiiwebIdentityInterface
URL Management
⦿ Optional parameters are now supported
⦿ Installing Yii
⦿ Generating Code with Gii
⦿ Handling Errors
⦿ Logging
⦿ Query Builder
⦿ Active Record
⦿ Migrations
⦿ Sphinx
⦿ Redis
⦿ MongoDB
⦿ ElasticSearch
⦿ Security
⦿ Caching
⦿ RESTful Web Services
⦿ Development Tools
⦿ Testing
Yii 2.0 Keys Success
⦿ Advanced Application Template
⦿ Console Commands
⦿ Core Validators
⦿ Internationalization
⦿ Mailing
⦿ Template Engines
⦿ Working with Third-Party Code
⦿ GridView
⦿ ListView
⦿ DetailView
⦿ Pjax
⦿ Menu
⦿ LinkPager
⦿ LinkSorter
⦿ Bootstrap Widgets
⦿ Jquery UI Widgets

Yii2 by Peter Jack Kambey

  • 1.
    Peter J. Kambey– Yii Enthusiasm HIGH PERFORMANCE & BEST FEATURES YII-2
  • 2.
  • 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.
  • 4.
    A. Non YiiUsers / New Comers
  • 5.
  • 6.
  • 7.
    What is YiiBest for?
  • 8.
    Yii vs OtherFrameworks? • 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.
  • 9.
  • 10.
  • 11.
    Namespaces ⦿ Prefixes nolonger used ⦿ Based on directory structure e.g. yiiwebRequest
  • 12.
    Events ⦿ onEvent methoddefinition no longer needed ⦿ $component->on($eventName, $handler);
  • 13.
    Path Alias ⦿ Mustuse @ ⦿ @yii means Yii installation directory ⦿ Closely related to class namespaces
  • 14.
    View Class ⦿ $thisin a view no longer means controller or widget object ⦿ Smarty and Twig support added ⦿ Prado support removed
  • 15.
    Models ⦿ formName() returnsthe 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() andrenderPartial() 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 isgone ⦿ 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
  • 19.
    Console applications ⦿ Controllers ⦿Console and web controllers have same base class ⦿ Console controller is similar to CConsoleCommand
  • 20.
    Internationalisation (i18n) ⦿ Dateand number formatter are out ⦿ PECL intl php module is in ⦿ I18n application component
  • 21.
    ActiveForm ⦿ Field: label,input, error message and hint text
  • 22.
    Query Builder ⦿ CDbCommand,CDbCriteria, CDbCommandBuilder ⦿ yiidbQuery|Query = DB ⦿ yiidbQueryBuilder|QueryBuilder = Query
  • 23.
    Active Record ⦿ yiidbActiveRecord|ActiveRecord ⦿Relational AR Query ⦿ 1.1 = relations() ⦿ 2.0 = getter methods
  • 24.
    Active Record ⦿ Nolonger uses model(), but uses the find method:
  • 25.
    User and IdentityInterface ⦿CWebuser is now yiiwebUser ⦿ CUserIdentity is no more ⦿ yiiwebIdentityInterface
  • 26.
    URL Management ⦿ Optionalparameters are now supported
  • 27.
    ⦿ Installing Yii ⦿Generating Code with Gii ⦿ Handling Errors ⦿ Logging ⦿ Query Builder ⦿ Active Record ⦿ Migrations ⦿ Sphinx ⦿ Redis ⦿ MongoDB ⦿ ElasticSearch ⦿ Security ⦿ Caching ⦿ RESTful Web Services ⦿ Development Tools ⦿ Testing Yii 2.0 Keys Success ⦿ Advanced Application Template ⦿ Console Commands ⦿ Core Validators ⦿ Internationalization ⦿ Mailing ⦿ Template Engines ⦿ Working with Third-Party Code ⦿ GridView ⦿ ListView ⦿ DetailView ⦿ Pjax ⦿ Menu ⦿ LinkPager ⦿ LinkSorter ⦿ Bootstrap Widgets ⦿ Jquery UI Widgets