Yii2 dev digest #8 May-Jun'14
Jun 10, 2014, 7:57:23 PMMay was a good time for a barbeque and trekking :) So here is a brief digest, hopefully not so much news means more bugfix and docs work from Yii Team towards stable RC.
- Documentation translation is started. Select some ready made En guide section and move on like Ru example.
- A lot of docs are being updated and added. Reminder - docs are here
- The Yii2 guide will also be available as PDF soon. First very rough draft is uploaded here: http://stuff.cebe.cc/yii2-guide.pdf
- Yii 2.0 review slides by Alexander Makarov
- What new PHP features do you need to learn to understand Yii2
- Yii 2 list of path aliases available with default basic and advanced app
- WIP Bower package manager / non-PHP dependencies. @pmoust tries to integrate it with BowerPHP
- No Ubuntu Juju Charms support out of the box.
-
...since nowadays nginx usage is very high and .htaccess is useless for it and many other webservers.
Events partial wildcard matching not planned to have
- Added
export()
andexportAsString()
. Kind-a ownvar_export
- kPHP in Yii framework? Definetily not, while kPHP does not support OOP.
- Added
truncate
andtruncateWords
methods. Cool, I was writing own implementations for blog :) - Added support for using conditional comments for js and css files registered through asset bundles and Html helper
- Docs : Using template engines (Twig, Smarty)
- API dicsussion : add multi-level relations to ActiveRecord::extraFields()
- Vkontakte oAuth support
- RBAC tables are made via migration now
- Discussion: Eager loading of the statistical relations could apperar in RC
- Discussion: RESTful service client
Try Yii2 in one click with Vagrant VM + Ansible provisioning
See all details in my previous post.. All software you wanted to try with Yii2 installed and provisioned out of the box.
In two words :
"Try Yii2" provides you with Vagrant file and Ansible provsioning scripts. Vagrant will launch the VirtualBox VM, download OS image, deploy it and then run Ansible. It will set up all needed software inside Linux VM, clone Yii2 project, download test DB and connect it with project. Also Vagrant will modify you hosts
file and assign special local domain adresses with VM IP address, so you will be able to access test Yii2 prject by humanreadable local domain name. All these steps will be made completely automatically, just run vagrant up
and wait !
Yii2 Extensions
- BlueImp File Upload Widget for Yii2
- Disqus Widget
- Yii2 Bootstrap form helpers library, demos here
- Multi Select Widget
- Yii2 Solr
- Yii2 Gridview Editable
- Yii 2 Extension to manage Role Base Access Control
- Yii2 Leaflet (Maps)
- Yii2 Ckeditor
- Yii2-EAV
Yii2 Tips & Tricks
How to use yii2-authclient to communicate with Twitter using Single Access Token
How to change server address of the asset files being delivered ?
You should configure AssetBundle::baseUrl which may contain the host info you need.
How to Input array for Active Fields ?
$form->field($model, 'uploadFile[]')->fileInput('multiple'=>'multiple');
$handler = new \app\components\ApiErrorHandler;
\Yii::$app->set('errorHandler', $handler);
$handler->register();
Is there an alternative for findByPk from Yii1 ?
Here is code example https://github.com/yiisoft/yii2/issues/3390
'rules' => [
[
'class' => 'yii\rest\UrlRule',
'controller' => 'user',
'tokens' => ['{id}' => '<id:[a-z0-9]*>']
],
],
How can i pass params for layout for breadcrumbs?
In controller:
$this->view->params['breadcrumbs'] = [...];
In view:print_r($this->params['breadcrumbs']);
How do i include image file using assets?
After you call
$bundle = YourAssetBundle::register($this);
, you can use$bundle->baseUrl
and prefix it to the image path in the image tag. Yii won't do automatic replacement like you said. Unless you are developing an extension, you normally don't need to put images in an asset bundle. You should directly put them under Web accessible folders.