PHP code example of matih / yii2-one-domain-starter-kit
1. Go to this page and download the library: Download matih/yii2-one-domain-starter-kit library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
matih / yii2-one-domain-starter-kit example snippets
common/config/base.php
'bootstrap' => ['maintenance'],
...
'components' => [
...
'maintenance' => [
'class' => 'common\components\maintenance\Maintenance',
'enabled' => Astronomy::isAFullMoonToday()
]
...
]
$sendEmailCommand = new SendEmailCommand(['to' => '[email protected] ', 'body' => 'Hello User!']);
Yii::$app->commandBus->handle($sendEmailCommand);
$addToTimelineCommand = new AddToTimelineCommand([
'category' => 'user',
'event' => 'signup',
'data' => ['foo' => 'bar']
]);
Yii::$app->commandBus->handle($addToTimelineCommand);
public function behaviors()
{
return [
[
'class' => `common\behaviors\CacheInvalidateBehavior`,
'tags' => [
'awesomeTag',
function($model){
return "tag-{$model->id}"
}
],
'keys' => [
'awesomeKey',
function($model){
return "key-{$model->id}"
}
]
],
];
}
'as globalAccess'=>[
'class'=>'\common\behaviors\GlobalAccessBehavior',
'rules'=>[
[
'controllers'=>['sign-in'],
'allow' => true,
'roles' => ['?'],
'actions'=>['login']
],
[
'controllers'=>['sign-in'],
'allow' => true,
'roles' => ['@'],
'actions'=>['logout']
],
[
'controllers'=>['site'],
'allow' => true,
'roles' => ['?', '@'],
'actions'=>['error']
],
[
'allow' => true,
'roles' => ['@']
]
]
]
echo DbCarousel::widget(['key' => 'key-from-backend'])
echo DbText::widget(['key' => 'key-from-backend'])
echo DbMenu::widget(['key' => 'key-from-backend'])
[
'class' => '\common\grid\EnumColumn',
'attribute' => 'status',
'enum' => User::getStatuses() // [0=>'Deleted', 1=>'Active']
]
$model = new MultiModel([
'models' => [
'user' => $userModel,
'profile' => $userProfileModel
]
]);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
...
}
echo $form->field($model->getModel('account'), 'username')
Yii::$app->user->can('editOwnModel', ['model' => $model]);
public function behaviors()
{
return [
'modelAccess' => [
'class' => OwnModelAccessFilter::className(),
'only' => ['view', 'update', 'delete'],
'modelClass' => Article::className()
],
];
}
php console/yii message/migrate @common/config/messages/php.php @common/config/messages/db.php