SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Downloaden Sie, um offline zu lesen
Yii 2   What’s new?




               Alexander Makarov,
                     Yii core team
Some statistics
Who uses Yii?
*intranet
2   2
Why?
1.Well-balanced
2.Stable
3.Flexible
4.Well-documented
2011 — beginning of 2012 events
What happened?
• 5 stable Yii 1.1 releases   • Events:
• Yii 1.1 Application           – Yii beer party
  Development Cookbook          – YiiTalk
• Yii for Eclipse PDT,          – YiiConf
  CodeLobster
• Yii → GitHub
First two days
—348 watches
—61 forks
Now
—1134 watches
—240 forks
Yii 1.1.11 will be quite interesting
             release ;)
What’s bad in Yii 1.1?
• AR (finder and record are the same object,
  some API).
• Some classes are in strange places.
• More small things.



     The biggest issue is
                               BC
*
              *                 *



       *                                          
2004       2005   2006   2007       2008   2011




Prado, from 2004 → Yii 1.0, 2008 → Yii 1.1, 2010
Yii 2 team


—3 active core developers: qiang, samdark,
 mdomba.
—github.
—PHP 5.3.8+              —Better structure
—All classes are         —Less entities
 namespaced (yii) and   —Keep good ideas
 w/o prefix
—PSR-0




                                    v2
Documentation
—Larry Ullman, author of 22 excellent IT-books
 and a great article series about Yii will write a
 book about Yii2 + will participate in official
 documentation writing.
—API docs will be at least same quality as 1.1.
—Code style guide.
—There’s a plan to release documentation tool
 to the public.
Yii2: base
— Aliases in form of     class MyComponent extends
  @yii/base/Component    yiibaseObject
                         {
— CComponent →             public $x;
  Object + Component       public function __construct($a, $b)
— SPL replaced most of     {
  collections                  //…
                           }
— Removed
                         }
  CFormModel. Now
  you can use Model      $component = MyComponent::newInstance(
  directly.                array('x'=>10),
                           'a', 'b'
                         );
Yii2: View Object
         —render(), widget(),
          beginCache() →
          viewObject
         —In a View: $owner =
          class that uses view
         —$this = View.
         —No need for renderer.
         —Can be used in console
          applications.
         —CHtml is still there.
Yii2: events
$post->on('add',          • No need to
function($event) { ...      explicitly declare
});                         before raising
                          • jQuery-like syntax
$post->trigger('add',     • Behaviors instead of
new Event($this));          filters

$post->off('add',
$callback);

$handlers = $post-
>getEventHandlers('add'
);
Yii2: Query object

// Query object
$query = new Query;
$query->select('id')->from('tbl_customer')->limit(10);
$command = $db->createCommand($query);
$this->assertEquals("SELECT `id` FROM `tbl_customer`
LIMIT 10", $command->sql);

// array
$command = $db->createCommand(array(
       'select' => 'name',
       'from' => 'tbl_customer',
));
Yii2: AR
$customer = Customer::find(2)   – Finder / Model
       ->active()               – Can create your own
       ->one();                   finder
$customer->name = 'Qiang';
                                – ::model()
$customer->save();
                                – Auto quoting.
$customers = Customer::find()   – Method chains.
       ->order('id')
       ->asArray(true)
       ->all();
Yii2: AR
$postFinder = Post::find()       – Criteria
  ->where(array(                 – Can merge two finders
    'active' => true
                                 – Can add conditions on
));
                                   the fly
if($isPrivate) {
  $postFinder->addWhere(array(
    'createdBy' => $userId,
  ));
}
$posts = $postFinder
  ->mergeWith($anotherFinder)
  ->all();
Yii2: AR
                            class Customer extends ActiveRecord {
– tableName(),                      const STATUS_ACTIVE = 1;
  relations(), scopes() =
                                    public static function tableName() {
  static.                                   return 'tbl_customer';

– Relations are                     }

  HAS_ONE,                          public static function relations() {

  HAS_MANY.                                 return array(
                                                    'orders:Order[]' => array(
– link = FKs                => 'id'),
                                                            'link' => array('customer_id'


– via = through                             );
                                                    ),


– Anonymous functions               }

  for scopes.                       public static function scopes() {

– "@." and "?" tokens:                      return array(
                                                    'active' => function($q) {
  own table, external                                       return $q-
                            >andWhere('@.`status` = ' . self::STATUS_ACTIVE);
  table.                                            },
                                            );
                                    }
                            }
Yii2: AR
$customers =                 $customers =
Customer::find()->           Customer::find()->active()
asArray()->all();            ->all();

foreach (Customer::find()    $customers =
as $customer)                Customer::find()
                             ->where('name like :name',
$count = Customer::count()   array(
->value();                     ':name' => '%customer%‘
                             ))->order('id')->all();
TODO (if there will be enough time)
•   HTTP (CURL) wrapper    • jQueryUI-based widgets
•   Package manager        • Commercial support
•   Mailer
•   Twitter Bootstrap
•   Debug toolbar
•   Console requirements
•   More helpers
1 or 2?



Don’t wait. Work with stable one.
When?
Before alpha code will be   •   Base for caching
put into public github      •   Base for i18n
repository we need to       •   Controller + webapp
finish at least these
things→                     •   Base for widgets
                            •   URL manager
Want more info?
—http://www.yiiframework.co
 m/forum/index.php/forum/4
 2-design-discussions-for-yii-
 20/
Questions?


yiiframework.com
 yiiframework.ru
   rmcreative.ru

Weitere ähnliche Inhalte

Was ist angesagt?

Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010
Rob Windsor
 
A Persistence Service for the OSGi Framework - Carl Rosenberger, Chief Softwa...
A Persistence Service for the OSGi Framework - Carl Rosenberger, Chief Softwa...A Persistence Service for the OSGi Framework - Carl Rosenberger, Chief Softwa...
A Persistence Service for the OSGi Framework - Carl Rosenberger, Chief Softwa...
mfrancis
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP Framework
Bo-Yi Wu
 

Was ist angesagt? (19)

State of search | drupal dinner
State of search | drupal dinnerState of search | drupal dinner
State of search | drupal dinner
 
C# advanced topics and future - C#5
C# advanced topics and future - C#5C# advanced topics and future - C#5
C# advanced topics and future - C#5
 
Real World Asp.Net WebApi Applications
Real World Asp.Net WebApi ApplicationsReal World Asp.Net WebApi Applications
Real World Asp.Net WebApi Applications
 
Intorduction of Playframework
Intorduction of PlayframeworkIntorduction of Playframework
Intorduction of Playframework
 
Maximizer 2018 API training
Maximizer 2018 API trainingMaximizer 2018 API training
Maximizer 2018 API training
 
OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015
 
How to get full power from WebApi
How to get full power from WebApiHow to get full power from WebApi
How to get full power from WebApi
 
Introduction to Monsoon PHP framework
Introduction to Monsoon PHP frameworkIntroduction to Monsoon PHP framework
Introduction to Monsoon PHP framework
 
JWT - Sécurisez vos APIs
JWT - Sécurisez vos APIsJWT - Sécurisez vos APIs
JWT - Sécurisez vos APIs
 
PHP, OAuth, Web Services and YQL
PHP, OAuth, Web Services and YQLPHP, OAuth, Web Services and YQL
PHP, OAuth, Web Services and YQL
 
Introduction to the SharePoint 2013 REST API
Introduction to the SharePoint 2013 REST APIIntroduction to the SharePoint 2013 REST API
Introduction to the SharePoint 2013 REST API
 
Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010
 
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
 
Life outside WO
Life outside WOLife outside WO
Life outside WO
 
[2015/2016] JavaScript
[2015/2016] JavaScript[2015/2016] JavaScript
[2015/2016] JavaScript
 
SharePoint 2013 APIs
SharePoint 2013 APIsSharePoint 2013 APIs
SharePoint 2013 APIs
 
A Persistence Service for the OSGi Framework - Carl Rosenberger, Chief Softwa...
A Persistence Service for the OSGi Framework - Carl Rosenberger, Chief Softwa...A Persistence Service for the OSGi Framework - Carl Rosenberger, Chief Softwa...
A Persistence Service for the OSGi Framework - Carl Rosenberger, Chief Softwa...
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP Framework
 
Resting with OroCRM Webinar
Resting with OroCRM WebinarResting with OroCRM Webinar
Resting with OroCRM Webinar
 

Andere mochten auch

1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.
1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.
1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.
Bicol IT.org
 

Andere mochten auch (15)

Yii PHP MVC Framework presentation silicongulf.com
Yii PHP MVC Framework presentation silicongulf.comYii PHP MVC Framework presentation silicongulf.com
Yii PHP MVC Framework presentation silicongulf.com
 
Yii Framework
Yii FrameworkYii Framework
Yii Framework
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplications
 
Yii Introduction
Yii IntroductionYii Introduction
Yii Introduction
 
Introduce Yii
Introduce YiiIntroduce Yii
Introduce Yii
 
Yii Training session-1
Yii Training session-1Yii Training session-1
Yii Training session-1
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in Yii
 
1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.
1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.
1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.
 
Devconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedDevconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developed
 
Yii workshop
Yii workshopYii workshop
Yii workshop
 
A site in 15 minutes with yii
A site in 15 minutes with yiiA site in 15 minutes with yii
A site in 15 minutes with yii
 
Yii framework
Yii frameworkYii framework
Yii framework
 
yii framework
yii frameworkyii framework
yii framework
 
Yii framework
Yii frameworkYii framework
Yii framework
 
Introduction Yii Framework
Introduction Yii FrameworkIntroduction Yii Framework
Introduction Yii Framework
 

Ähnlich wie YiiConf 2012 - Alexander Makarov - Yii2, what's new

Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.js
Jarod Ferguson
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
Night Sailer
 

Ähnlich wie YiiConf 2012 - Alexander Makarov - Yii2, what's new (20)

Yii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading toYii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading to
 
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
Migrare da symfony 1 a Symfony2
 Migrare da symfony 1 a Symfony2  Migrare da symfony 1 a Symfony2
Migrare da symfony 1 a Symfony2
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.js
 
Doctrine and NoSQL
Doctrine and NoSQLDoctrine and NoSQL
Doctrine and NoSQL
 
Doctrine for NoSQL
Doctrine for NoSQLDoctrine for NoSQL
Doctrine for NoSQL
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony Apps
 
Spl Not A Bridge Too Far phpNW09
Spl Not A Bridge Too Far phpNW09Spl Not A Bridge Too Far phpNW09
Spl Not A Bridge Too Far phpNW09
 
Min-Maxing Software Costs
Min-Maxing Software CostsMin-Maxing Software Costs
Min-Maxing Software Costs
 
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersPHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4Developers
 
Your code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConYour code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnCon
 
Lithium Best
Lithium Best Lithium Best
Lithium Best
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntity
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
You code sucks, let's fix it
You code sucks, let's fix itYou code sucks, let's fix it
You code sucks, let's fix it
 

Mehr von Alexander Makarov

UWDC 2013, Как мы используем Yii
UWDC 2013, Как мы используем YiiUWDC 2013, Как мы используем Yii
UWDC 2013, Как мы используем Yii
Alexander Makarov
 
DevConf 2012 - Yii, его разработка и Yii2
DevConf 2012 - Yii, его разработка и Yii2DevConf 2012 - Yii, его разработка и Yii2
DevConf 2012 - Yii, его разработка и Yii2
Alexander Makarov
 
YiiConf 2012 - Alexander Makarov - Yii2, что нового
YiiConf 2012 - Alexander Makarov - Yii2, что новогоYiiConf 2012 - Alexander Makarov - Yii2, что нового
YiiConf 2012 - Alexander Makarov - Yii2, что нового
Alexander Makarov
 
UWDC'12, Александр Макаров, Yii, его разработка и Yii2
UWDC'12, Александр Макаров, Yii, его разработка и Yii2UWDC'12, Александр Макаров, Yii, его разработка и Yii2
UWDC'12, Александр Макаров, Yii, его разработка и Yii2
Alexander Makarov
 
UWDC'12, Александр Макаров, О командной разработке и фреймворках
UWDC'12, Александр Макаров, О командной разработке и фреймворкахUWDC'12, Александр Макаров, О командной разработке и фреймворках
UWDC'12, Александр Макаров, О командной разработке и фреймворках
Alexander Makarov
 
Выбираем PHP-фреймворк. Особенности разработки с фреймворками
Выбираем PHP-фреймворк. Особенности разработки с фреймворкамиВыбираем PHP-фреймворк. Особенности разработки с фреймворками
Выбираем PHP-фреймворк. Особенности разработки с фреймворками
Alexander Makarov
 

Mehr von Alexander Makarov (10)

UWDC 2013, Как мы используем Yii
UWDC 2013, Как мы используем YiiUWDC 2013, Как мы используем Yii
UWDC 2013, Как мы используем Yii
 
UWDC 2013, Yii2
UWDC 2013, Yii2UWDC 2013, Yii2
UWDC 2013, Yii2
 
DevConf 2012 - Yii, его разработка и Yii2
DevConf 2012 - Yii, его разработка и Yii2DevConf 2012 - Yii, его разработка и Yii2
DevConf 2012 - Yii, его разработка и Yii2
 
YiiConf 2012 - Alexander Makarov - Yii2, что нового
YiiConf 2012 - Alexander Makarov - Yii2, что новогоYiiConf 2012 - Alexander Makarov - Yii2, что нового
YiiConf 2012 - Alexander Makarov - Yii2, что нового
 
UWDC'12, Александр Макаров, Yii, его разработка и Yii2
UWDC'12, Александр Макаров, Yii, его разработка и Yii2UWDC'12, Александр Макаров, Yii, его разработка и Yii2
UWDC'12, Александр Макаров, Yii, его разработка и Yii2
 
UWDC'12, Александр Макаров, О командной разработке и фреймворках
UWDC'12, Александр Макаров, О командной разработке и фреймворкахUWDC'12, Александр Макаров, О командной разработке и фреймворках
UWDC'12, Александр Макаров, О командной разработке и фреймворках
 
Devconf 2011 - PHP - Как разрабатывается фреймворк Yii
Devconf 2011 - PHP - Как разрабатывается фреймворк YiiDevconf 2011 - PHP - Как разрабатывается фреймворк Yii
Devconf 2011 - PHP - Как разрабатывается фреймворк Yii
 
Как разраба
Как разрабаКак разраба
Как разраба
 
Выбираем PHP-фреймворк. Особенности разработки с фреймворками
Выбираем PHP-фреймворк. Особенности разработки с фреймворкамиВыбираем PHP-фреймворк. Особенности разработки с фреймворками
Выбираем PHP-фреймворк. Особенности разработки с фреймворками
 
Yii rit 2010
Yii rit 2010Yii rit 2010
Yii rit 2010
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

YiiConf 2012 - Alexander Makarov - Yii2, what's new

  • 1. Yii 2 What’s new? Alexander Makarov, Yii core team
  • 2.
  • 4.
  • 5.
  • 8.
  • 9. 2 2
  • 10. Why?
  • 12. 2011 — beginning of 2012 events
  • 13. What happened? • 5 stable Yii 1.1 releases • Events: • Yii 1.1 Application – Yii beer party Development Cookbook – YiiTalk • Yii for Eclipse PDT, – YiiConf CodeLobster • Yii → GitHub
  • 14.
  • 15. First two days —348 watches —61 forks
  • 17. Yii 1.1.11 will be quite interesting release ;)
  • 18. What’s bad in Yii 1.1? • AR (finder and record are the same object, some API). • Some classes are in strange places. • More small things. The biggest issue is BC
  • 19. * * * *  2004 2005 2006 2007 2008 2011 Prado, from 2004 → Yii 1.0, 2008 → Yii 1.1, 2010
  • 20. Yii 2 team —3 active core developers: qiang, samdark, mdomba. —github.
  • 21. —PHP 5.3.8+ —Better structure —All classes are —Less entities namespaced (yii) and —Keep good ideas w/o prefix —PSR-0 v2
  • 22. Documentation —Larry Ullman, author of 22 excellent IT-books and a great article series about Yii will write a book about Yii2 + will participate in official documentation writing. —API docs will be at least same quality as 1.1. —Code style guide. —There’s a plan to release documentation tool to the public.
  • 23. Yii2: base — Aliases in form of class MyComponent extends @yii/base/Component yiibaseObject { — CComponent → public $x; Object + Component public function __construct($a, $b) — SPL replaced most of { collections //… } — Removed } CFormModel. Now you can use Model $component = MyComponent::newInstance( directly. array('x'=>10), 'a', 'b' );
  • 24. Yii2: View Object —render(), widget(), beginCache() → viewObject —In a View: $owner = class that uses view —$this = View. —No need for renderer. —Can be used in console applications. —CHtml is still there.
  • 25. Yii2: events $post->on('add', • No need to function($event) { ... explicitly declare }); before raising • jQuery-like syntax $post->trigger('add', • Behaviors instead of new Event($this)); filters $post->off('add', $callback); $handlers = $post- >getEventHandlers('add' );
  • 26. Yii2: Query object // Query object $query = new Query; $query->select('id')->from('tbl_customer')->limit(10); $command = $db->createCommand($query); $this->assertEquals("SELECT `id` FROM `tbl_customer` LIMIT 10", $command->sql); // array $command = $db->createCommand(array( 'select' => 'name', 'from' => 'tbl_customer', ));
  • 27. Yii2: AR $customer = Customer::find(2) – Finder / Model ->active() – Can create your own ->one(); finder $customer->name = 'Qiang'; – ::model() $customer->save(); – Auto quoting. $customers = Customer::find() – Method chains. ->order('id') ->asArray(true) ->all();
  • 28. Yii2: AR $postFinder = Post::find() – Criteria ->where(array( – Can merge two finders 'active' => true – Can add conditions on )); the fly if($isPrivate) { $postFinder->addWhere(array( 'createdBy' => $userId, )); } $posts = $postFinder ->mergeWith($anotherFinder) ->all();
  • 29. Yii2: AR class Customer extends ActiveRecord { – tableName(), const STATUS_ACTIVE = 1; relations(), scopes() = public static function tableName() { static. return 'tbl_customer'; – Relations are } HAS_ONE, public static function relations() { HAS_MANY. return array( 'orders:Order[]' => array( – link = FKs => 'id'), 'link' => array('customer_id' – via = through ); ), – Anonymous functions } for scopes. public static function scopes() { – "@." and "?" tokens: return array( 'active' => function($q) { own table, external return $q- >andWhere('@.`status` = ' . self::STATUS_ACTIVE); table. }, ); } }
  • 30. Yii2: AR $customers = $customers = Customer::find()-> Customer::find()->active() asArray()->all(); ->all(); foreach (Customer::find() $customers = as $customer) Customer::find() ->where('name like :name', $count = Customer::count() array( ->value(); ':name' => '%customer%‘ ))->order('id')->all();
  • 31. TODO (if there will be enough time) • HTTP (CURL) wrapper • jQueryUI-based widgets • Package manager • Commercial support • Mailer • Twitter Bootstrap • Debug toolbar • Console requirements • More helpers
  • 32. 1 or 2? Don’t wait. Work with stable one.
  • 33. When? Before alpha code will be • Base for caching put into public github • Base for i18n repository we need to • Controller + webapp finish at least these things→ • Base for widgets • URL manager
  • 34. Want more info? —http://www.yiiframework.co m/forum/index.php/forum/4 2-design-discussions-for-yii- 20/