Yii Conferencia Apresentacao

download Yii Conferencia Apresentacao

of 35

Transcript of Yii Conferencia Apresentacao

  • 7/28/2019 Yii Conferencia Apresentacao

    1/35

    Yii2Whats new?

    Alexander Makarov,

    Yii core team

  • 7/28/2019 Yii Conferencia Apresentacao

    2/35

  • 7/28/2019 Yii Conferencia Apresentacao

    3/35

    Some statistics

  • 7/28/2019 Yii Conferencia Apresentacao

    4/35

  • 7/28/2019 Yii Conferencia Apresentacao

    5/35

  • 7/28/2019 Yii Conferencia Apresentacao

    6/35

    Who uses

    Yii

    ?

  • 7/28/2019 Yii Conferencia Apresentacao

    7/35

    *intranet

    http://rtrn.ru/http://rtrn.ru/http://listick.ru/http://www.alawar.ru/http://php.ru/http://rtrn.ru/http://fezeev.livejournal.com/50545.htmlhttp://2gis.ru/http://www.trud.com/http://kuponator.ru/http://www.e5.ru/http://billkill.ru/http://66.ru/
  • 7/28/2019 Yii Conferencia Apresentacao

    8/35

    http://www.rocket-internet.de/?lang=enhttp://www.edarling.de/http://www.clevertech.biz/yii/http://www.zalando.de/http://www.qippo.com/http://meetfriends.rt.com/http://www.nutritionix.com/http://uniprogy.com/http://www.vice.com/http://turnapi.com/http://www.realself.com/http://piclyf.com/http://www.noisey.com/http://curisma.com/http://www.stay.com/
  • 7/28/2019 Yii Conferencia Apresentacao

    9/35

    22

    http://www.limesurvey.org/http://www.limesurvey.org/http://www.mybb.com/http://zurmo.org/http://www.x2engine.com/http://www.chive-project.com/
  • 7/28/2019 Yii Conferencia Apresentacao

    10/35

    Why?

  • 7/28/2019 Yii Conferencia Apresentacao

    11/35

    1.Well-balanced

    2.Stable3.Flexible

    4.Well-documented

  • 7/28/2019 Yii Conferencia Apresentacao

    12/35

    2011 beginning of2012 events

  • 7/28/2019 Yii Conferencia Apresentacao

    13/35

    What happened?

    5 stable Yii 1.1 releases

    Yii 1.1 Application

    Development Cookbook

    Yii for Eclipse PDT,CodeLobster

    Yii GitHub

    Events:

    Yii beer party

    YiiTalk

    YiiConf

  • 7/28/2019 Yii Conferencia Apresentacao

    14/35

  • 7/28/2019 Yii Conferencia Apresentacao

    15/35

    First two days

    348 watches

    61 forks

  • 7/28/2019 Yii Conferencia Apresentacao

    16/35

    Now

    1134 watches

    240 forks

  • 7/28/2019 Yii Conferencia Apresentacao

    17/35

    Yii 1.1.11 will be quite interesting

    release ;)

  • 7/28/2019 Yii Conferencia Apresentacao

    18/35

    Whats bad in Yii 1.1?

    AR (finder and record are the same object,

    some API).

    Some classes are in strange places.

    More small things.

    BCThe biggest issue is

  • 7/28/2019 Yii Conferencia Apresentacao

    19/35Prado, from 2004 Yii 1.0, 2008 Yii 1.1, 2010

    2004 2005 2007 2008

    ***

    *

    20112006

  • 7/28/2019 Yii Conferencia Apresentacao

    20/35

    Yii 2 team

    3 active core developers: qiang, samdark,mdomba.

    github.

  • 7/28/2019 Yii Conferencia Apresentacao

    21/35

    PHP 5.3.8+

    All classes are

    namespaced (\yii) and

    w/o prefixPSR-0

    Better structure

    Less entities

    Keep good ideas

    v2

  • 7/28/2019 Yii Conferencia Apresentacao

    22/35

    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.

    Theres a plan to release documentation tool

    to the public.

  • 7/28/2019 Yii Conferencia Apresentacao

    23/35

    Yii2: base

    Aliases in form of@yii/base/Component

    CComponentObject + Component

    SPL replaced most ofcollections

    RemovedCFormModel. Nowyou can use Model

    directly.

    class MyComponent extends\yii\base\Object

    {

    public $x;

    public function __construct($a, $b)

    {//

    }

    }

    $component = MyComponent::newInstance(

    array('x'=>10),

    'a', 'b'

    );

  • 7/28/2019 Yii Conferencia Apresentacao

    24/35

    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 consoleapplications.

    CHtml is still there.

  • 7/28/2019 Yii Conferencia Apresentacao

    25/35

    Yii2: events

    $post->on('add',function($event) { ...});

    $post->trigger('add',new Event($this));

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

    $handlers = $post->getEventHandlers('add');

    No need toexplicitly declarebefore raising

    jQuery-like syntax

    Behaviors instead offilters

  • 7/28/2019 Yii Conferencia Apresentacao

    26/35

    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',

    ));

  • 7/28/2019 Yii Conferencia Apresentacao

    27/35

    Yii2: AR

    $customer = Customer::find(2)

    ->active()

    ->one();

    $customer->name = 'Qiang';

    $customer->save();

    $customers = Customer::find()

    ->order('id')

    ->asArray(true)

    ->all();

    Finder / Model

    Can create your own

    finder

    ::model()

    Auto quoting.

    Method chains.

  • 7/28/2019 Yii Conferencia Apresentacao

    28/35

    Yii2: AR

    $postFinder = Post::find()

    ->where(array(

    'active' => true

    ));

    if($isPrivate) {$postFinder->addWhere(array(

    'createdBy' => $userId,

    ));

    }

    $posts = $postFinder

    ->mergeWith($anotherFinder)

    ->all();

    Criteria

    Can merge two finders

    Can add conditions on

    the fly

  • 7/28/2019 Yii Conferencia Apresentacao

    29/35

    Yii2: AR

    tableName(),relations(), scopes() =static.

    Relations areHAS_ONE,

    HAS_MANY.

    link = FKs

    via = through

    Anonymous functions

    for scopes. "@." and "?" tokens:

    own table, externaltable.

    class Customer extends ActiveRecord {

    const STATUS_ACTIVE = 1;

    public static function tableName() {

    return 'tbl_customer';

    }

    public static function relations() {

    return array(

    'orders:Order[]' => array(

    'link' => array('customer_id'

    => 'id'),

    ),

    );

    }

    public static function scopes() {return array(

    'active' => function($q) {

    return $q-

    >andWhere('@.`status` = ' . self::STATUS_ACTIVE);

    },

    );

    }

    }

  • 7/28/2019 Yii Conferencia Apresentacao

    30/35

    Yii2: AR

    $customers =

    Customer::find()->

    asArray()->all();

    foreach (Customer::find()as $customer)

    $count = Customer::count()

    ->value();

    $customers =

    Customer::find()->active()

    ->all();

    $customers =Customer::find()

    ->where('name like :name',

    array(

    ':name' => '%customer%

    ))->order('id')->all();

  • 7/28/2019 Yii Conferencia Apresentacao

    31/35

    TODO (if there will be enough time)

    HTTP (CURL) wrapper

    Package manager

    Mailer

    Twitter Bootstrap

    Debug toolbar

    Console requirements

    More helpers

    jQueryUI-based widgets

    Commercial support

  • 7/28/2019 Yii Conferencia Apresentacao

    32/35

    1 or 2?

    Dont wait. Work with stable one.

  • 7/28/2019 Yii Conferencia Apresentacao

    33/35

    When?

    Before alpha code will be

    put into public github

    repository we need to

    finish at least thesethings

    Base for caching

    Base for i18n

    Controller + webapp

    Base for widgets

    URL manager

  • 7/28/2019 Yii Conferencia Apresentacao

    34/35

    Want more info?

    http://www.yiiframework.co

    m/forum/index.php/forum/4

    2-design-discussions-for-yii-

    20/

    http://www.yiiframework.com/forum/index.php/forum/42-design-discussions-for-yii-20/http://www.yiiframework.com/forum/index.php/forum/42-design-discussions-for-yii-20/http://www.yiiframework.com/forum/index.php/forum/42-design-discussions-for-yii-20/http://www.yiiframework.com/forum/index.php/forum/42-design-discussions-for-yii-20/http://www.yiiframework.com/forum/index.php/forum/42-design-discussions-for-yii-20/http://www.yiiframework.com/forum/index.php/forum/42-design-discussions-for-yii-20/http://www.yiiframework.com/forum/index.php/forum/42-design-discussions-for-yii-20/http://www.yiiframework.com/forum/index.php/forum/42-design-discussions-for-yii-20/
  • 7/28/2019 Yii Conferencia Apresentacao

    35/35

    Questions?

    yiiframework.com

    yiiframework.ru

    rmcreative.ru

    http://yiiframework.com/http://yiiframework.ru/http://rmcreative.ru/http://rmcreative.ru/http://yiiframework.ru/http://yiiframework.com/