Professional Documents
Culture Documents
Yii
Whats new?
Alexander Makarov,
Yii core team
Some statistics
*intranet
Why?
1.Well-balanced
2.Stable
3.Flexible
4.Well-documented
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
Now
1134 watches
240 forks
BC
2004
2005
2006
2007
2008
2011
Yii 2 team
PHP 5.3.8+
All classes are
namespaced (\yii) and
w/o prefix
PSR-0
Better structure
Less entities
Keep good ideas
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.
Theres a plan to release documentation tool
to the public.
Yii2: base
Aliases in form of
@yii/base/Component
CComponent
Object + Component
SPL replaced most of
collections
Removed
CFormModel. Now
you can use Model
directly.
Yii2: events
$post->on('add',
function($event) { ...
});
$post->trigger('add',
new Event($this));
$post->off('add',
$callback);
$handlers = $post>getEventHandlers('add'
);
No need to
explicitly declare
before raising
jQuery-like syntax
Behaviors instead of
filters
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.
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
Yii2: AR
tableName(),
relations(), scopes() =
static.
Relations are
HAS_ONE,
HAS_MANY.
link = FKs
via = through
Anonymous functions
for scopes.
"@." and "?" tokens:
own table, external
table.
Yii2: AR
$customers =
Customer::find()->
asArray()->all();
$customers =
Customer::find()->active()
->all();
foreach (Customer::find()
as $customer)
$customers =
Customer::find()
->where('name like :name',
array(
':name' => '%customer%
))->order('id')->all();
$count = Customer::count()
->value();
jQueryUI-based widgets
Commercial support
1 or 2?
When?
Before alpha code will be
put into public github
repository we need to
finish at least these
things
Questions?
yiiframework.com
yiiframework.ru
rmcreative.ru