SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
9.
Что же произошло?
• 5 стабильных версий • Окончательно вылезли
Yii 1.1 из «подполья»:
• Yii 1.1 Application – Yii beer party
Development Cookbook – YiiTalk
• Yii for Eclipse PDT, – YiiConf
CodeLobster
• Yii → GitHub
16.
—PHP 5.3.8+ —Улучшаем структуру
—Все классы в —Убиваем лишние
namespace (yii) и без сущности
префикса —Сохраняем плюсы
—PSR-0
v2
17.
Документация
—Larry Ullman, автор 22-х отличных IT-книг и
серии статей про Yii: книга + участие в
официальной документации.
—API не хуже 1.1.
—Code style.
—Есть план сделать тулзу для генерации API
применимой к пользовательским
приложениям… или вообще убить
перегенерацию.
18.
Yii2: base
— Алиасы вида class MyComponent extends
@yii/base/Component yiibaseObject
{
— CComponent → public $x;
Object + Component public function __construct($a, $b)
— SPL вместо {
большинства //…
коллекций }
}
— Убит CFormModel в
пользу Model $component = MyComponent::newInstance(
array('x'=>10),
'a', 'b'
);
19.
Yii2: View Object
— render(), widget(),
beginCache() →
viewObject
— В View: $owner = тот, кто
запустил метод
— $this = View.
— Не нужны renderer.
— Можно использовать в
консоли.
— CHtml никуда не делся.
22.
Yii2: AR
$customer = Customer::find(2) – Finder / Model
->active() – Можно сделать свой
->one(); finder
$customer->name = 'Qiang';
– ::model()
$customer->save();
– Автокавычки.
$customers = Customer::find() – Method chains.
->order('id')
->asArray(true)
->all();
23.
Yii2: AR
$postFinder = Post::find() – Criteria
->where(array( – Можно мёржить finder
'active' => true
– Можно дополнять
));
условия на ходу
if($isPrivate) {
$postFinder->addWhere(array(
'createdBy' => $userId,
));
}
$posts = $postFinder
->mergeWith($anotherFinder)
->all();
24.
Yii2: AR
– tableName(),
class Customer extends ActiveRecord {
const STATUS_ACTIVE = 1;
relations(), scopes() =
public static function tableName() {
static. return 'tbl_customer';
– Связи HAS_ONE, }
HAS_MANY. public static function relations() {
return array(
– link = FKs 'orders:Order[]' => array(
– via = through
'link' => array('customer_id'
=> 'id'),
– Анонимки для
),
);
scopes. }
– Токены "@." и "?. public static function scopes() {
return array(
Автоалиас. Своя 'active' => function($q) {
таблица. Внешняя return $q-
>andWhere('@.`status` = ' . self::STATUS_ACTIVE);
таблица. },
);
}
}
25.
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();
26.
TODO (если успеем)
• HTTP (CURL) wrapper • Виджеты на базе
• Package manager jQueryUI
• Mailer • Коммерческая
• Twitter Bootstrap поддержка
• Debug toolbar
• Console requirements
• More helpers
28.
Когда?
До альфы на github • Базу для кеша
нужно доделать, как • Базу для i18n
минимум, вот эти штуки • Controller + webapp
→
• Базу для виджетов
• URL manager
29.
Что почитать?
—http://www.yiiframework.co
m/forum/index.php/forum/4
2-design-discussions-for-yii-
20/