Github: https://github.com/yiisoft/yii2/blob/master/docs/guide/README.md
composer global require "fxp/composer-asset-plugin:~1.1.1"
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
# Set document root to be "basic/web"
DocumentRoot "path/to/basic/web"
<Directory "path/to/basic/web">
# use mod_rewrite for pretty URL support
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# ...other settings...
</Directory>
<?php echo \yii\widgets\ListView::widget([
'dataProvider'=>$dataProvider,
'pager'=>[
'hideOnSinglePage'=>true,
],
'summary'=>'',
'itemView'=>'_item',
'layout' => "{items}\n <tr class='lpagination'><td colspan=\"8\">{pager}</td></tr>",
'options' => [
'class'=>'main-wrapper'
],
'itemOptions' => [
'tag' => false,
],
'viewParams'=>[
'param' => $param
]
])?>
<?php echo $form->errorSummary($model,[
'class'=>'alert alert-warning alert-dismissible',
'header'=>' <button type="button" class="close" data-dismiss="alert" aria-hidden="true">�</button><h4><i class="icon fa fa-warning"></i> Please fix error!</h4>'
]); ?>
$recipes = Model::find()
->where(['in', 'id', $id])
->orderBy([\yii\db\Expression('FIELD (id, 1,2,3')])
->all();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => [
'defaultOrder' => [
'id' => SORT_DESC
]
],
'pagination' => [
'pageSize' => Yii::$app->keyStorage->get('pageSize', 15),
],
]);
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => false,
'messageConfig' => [
'charset' => 'UTF-8',
'from' => ['[email protected]' => 'App Name'],
],
'transport' => [
'class' => 'Swift_MailTransport',
],
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => false,
'messageConfig' => [
'charset' => 'UTF-8',
'from' => [ '[email protected]' => 'App Name'],
],
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => '[email protected]',
'password' => 'YourAppPass',
'port' => '587',
'encryption' => 'tls',
],
],
Send email
Yii::$app->mailer->compose()
->setTo('[email protected]')
->setFrom(['[email protected]' => 'App Name'])
....
Yii::$app->fileStorage->getFilesystem()->has(FileBaseUrl)
$path = Yii::getAlias('@storage'). '\cache';
$files = glob($path.'\*');
foreach($files as $file){
if(is_file($file))
unlink($file);
}