yii2 by peter jack kambey
DESCRIPTION
Introduction about Yii2 by Peter Jack KambeyTRANSCRIPT
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. yii\web\Request
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
⦿ yii\db\Query|Query = DB
⦿ yii\db\QueryBuilder|QueryBuilder =
Query
Active Record
⦿ yii\db\ActiveRecord|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 yii\web\User
⦿ CUserIdentity is no more
⦿ yii\web\IdentityInterface
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