PHPackages                             matih/yii2-one-domain-starter-kit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. matih/yii2-one-domain-starter-kit

ActiveProject[Framework](/categories/framework)

matih/yii2-one-domain-starter-kit
=================================

Yii2 One Domain Starter Kit Application Template

2.2.1(10y ago)3503BSD-3-ClausePHPPHP &gt;=5.5.0

Since Jul 23Pushed 10y ago3 watchersCompare

[ Source](https://github.com/matih/yii2-one-domain-starter-kit)[ Packagist](https://packagist.org/packages/matih/yii2-one-domain-starter-kit)[ RSS](/packages/matih-yii2-one-domain-starter-kit/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (29)Versions (24)Used By (0)

Yii 2 Starter Kit
=================

[](#yii-2-starter-kit)

[![Packagist](https://camo.githubusercontent.com/3c961055c590940577eb30a9b5ed2db094ab7ebdaa8803b3ea19e636c0268994/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74726e74762f796969322d737461727465722d6b69742e737667)](https://packagist.org/packages/trntv/yii2-starter-kit)[![Packagist](https://camo.githubusercontent.com/e24f14c18a3b6071d882b8fbf8cc0ca76f4fb909677ee1b8c09e1e82d3acab16/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74726e74762f796969322d737461727465722d6b69742e737667)](https://packagist.org/packages/trntv/yii2-starter-kit)[![PayPal donate button](https://camo.githubusercontent.com/0d6e4d8b50b5983a58205941b1a581b1305903393b7a39da574e3f60af3c7f5b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617970616c2d646f6e6174652d79656c6c6f772e737667)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X7UFA3F3ALPM8 "Donate once-off to this project using Paypal")[![Dependency Status](https://camo.githubusercontent.com/35685f760223cb45328fdc25bdda0fcdb55feb0d6e8419673928ccf5da0fc4f6/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7068702f74726e74763a796969322d737461727465722d6b69742f62616467652e737667)](https://www.versioneye.com/php/trntv:yii2-starter-kit)[![Build Status](https://camo.githubusercontent.com/65e52ff9b7b6219df4975e03a266fc255c930f43e5dbfbc11e202c53af760d4b/68747470733a2f2f7472617669732d63692e6f72672f74726e74762f796969322d737461727465722d6b69742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/trntv/yii2-starter-kit)

This is Yii2 one-domain start application template, Based on [yii2-starter-kit](https://github.com/trntv/yii2-starter-kit)

It was created and developing as a fast start for building an advanced sites based on Yii2.

It covers typical use cases for a new project and will help you not to waste your time doing the same work in every project

Before you start
----------------

[](#before-you-start)

Please, consider helping project via [contributions](https://github.com/trntv/yii2-starter-kit/issues) or [donations](#donations).

TABLE OF CONTENTS
-----------------

[](#table-of-contents)

- [Demo](#demo)
- [Features](#features)
- [Installation](docs/installation.md)
    - [Manual installation](docs/installation.md#manual-installation)
    - [Docker installation](docs/installation.md#docker-installation)
    - [Vagrant installation](docs/installation.md#vagrant-installation)
- [Application components](#application-components)
- [Console commands](docs/console.md)
- [Testing](docs/testing.md)
- [FAQ](docs/faq.md)
- [How to contribute?](#how-to-contribute)
- [Donations](#donations)
- [Have any questions](#have-any-questions)

\##DEMO Demo is hosted by awesome [Digital Ocean](https://m.do.co/c/d7f000191ea8)

Frontend:

Backend:

`administrator` role account

```
Login: webmaster
Password: webmaster

```

`manager` role account

```
Login: manager
Password: manager

```

`user` role account

```
Login: user
Password: user

```

FEATURES
--------

[](#features)

- Beautiful and open source dashboard theme for backend [AdminLTE 2](http://almsaeedstudio.com/AdminLTE)
- Translations: English, Spanish, Russian, Ukrainian, Chinese
- Translations Editor
- Language change action + behavior to choose locale based on browser preferred language
- Sign in, Sign up, profile(avatar, locale, personal data), email activation etc
- OAuth authorization
- User management
- RBAC with predefined `guest`, `user`, `manager` and `administrator` roles
- RBAC migrations support
- Content management components: articles, categories, static pages, editable menu, editable carousels, text blocks
- Key-value storage component
- Application settings form (based on KeyStorage component)
- Ready-to-go RESTful API module
- [File storage component + file upload widget](https://github.com/trntv/yii2-file-kit)
- On-demand thumbnail creation [trntv/yii2-glide](https://github.com/trntv/yii2-glide)
- Command Bus with queued and async tasks support [trntv/yii2-command-bus](https://github.com/trntv/yii2-command-bus)
- Useful behaviors (GlobalAccessBehavior, CacheInvalidateBehavior, MaintenanceBehavior)
- Yii2 log web interface
- Application timeline component
- Cache web controller
- Maintenance mode component ([more](#maintenance-mode))
- System information web interface
- dotenv support
- `ExtendedMessageController` with ability to replace source code language and migrate messages between message sources
- [Aceeditor widget](https://github.com/trntv/yii2-aceeditor)
- [Datetimepicker widget](https://github.com/trntv/yii2-bootstrap-datetimepicker),
- [Imperavi Reactor Widget](https://github.com/asofter/yii2-imperavi-redactor),
- [Elfinder Extension](https://github.com/MihailDev/yii2-elfinder)
- [Xhprof Debug panel](https://github.com/trntv/yii2-debug-xhprof)
- Extended IDE autocompletion
- Nginx config example
- Test-ready
- Docker support and Vagrant support
- Built-in [mailcatcher](http://mailcatcher.me/)
- Assets compression and concatenation
- [Some useful shortcuts](https://github.com/trntv/yii2-starter-kit/blob/master/common/helpers.php)
- many other features i'm lazy to write about :-)

Application Components
======================

[](#application-components)

### I18N

[](#i18n)

If you want to store application messages in DB and to have ability to edit them from backend, run:

```
php console/yii message/migrate @common/config/messages/php.php @common/config/messages/db.php

```

it will copy all existing messages to database

Then uncomment config for `DbMessageSource` in

```
common/config/base.php
```

### KeyStorage

[](#keystorage)

Key storage is a key-value storage to store different information. Application settings for example. Values can be stored both via api or by backend CRUD component.

```
Yii::$app->keyStorage->set('articles-per-page', 20);
Yii::$app->keyStorage->get('articles-per-page'); // 20

```

### Maintenance mode

[](#maintenance-mode)

Starter kit has built-in component to provide a maintenance functionality. All you have to do is to configure `maintenance`component in your config

```
'bootstrap' => ['maintenance'],
...
'components' => [
    ...
    'maintenance' => [
        'class' => 'common\components\maintenance\Maintenance',
        'enabled' => Astronomy::isAFullMoonToday()
    ]
    ...
]
```

This component will catch all incoming requests, set proper response HTTP headers (503, "Retry After") and show a maintenance message. Additional configuration options can be found in a corresponding class.

Starter kit configured to turn on maintenance mode if `frontend.maintenance` key in KeyStorage is set to `true`

### Command Bus

[](#command-bus)

- [What is command bus?](http://shawnmc.cool/command-bus)

In Starter Kit Command Bus pattern is implemented with [tactician](https://github.com/thephpleague/tactician) package and it's yii2 connector - [yii2-tactician](https://github.com/trntv/yii2-tactician)

Command are stored in `common/commands/command` directory, handlers in `common/commands/handler`

To execute command run

```
$sendEmailCommand = new SendEmailCommand(['to' => 'user@example.org', 'body' => 'Hello User!']);
Yii::$app->commandBus->handle($sendEmailCommand);
```

### Timeline (Activity)

[](#timeline-activity)

```
$addToTimelineCommand = new AddToTimelineCommand([
    'category' => 'user',
    'event' => 'signup',
    'data' => ['foo' => 'bar']
]);
Yii::$app->commandBus->handle($addToTimelineCommand);
```

### Behaviors

[](#behaviors)

#### CacheInvalidateBehavior

[](#cacheinvalidatebehavior)

```
 public function behaviors()
 {
     return [
         [
             'class' => `common\behaviors\CacheInvalidateBehavior`,
             'tags' => [
                  'awesomeTag',
                   function($model){
                       return "tag-{$model->id}"
                  }
              ],
             'keys' => [
                  'awesomeKey',
                  function($model){
                      return "key-{$model->id}"
                  }
              ]
         ],
     ];
 }
```

#### GlobalAccessBehavior

[](#globalaccessbehavior)

Add in your application config:

```
'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' => ['@']
			]
        ]
    ]
```

It will allow access to you application only for authentificated users.

### Command Bus

[](#command-bus-1)

Read more about command bus on in [official repository](https://github.com/trntv/yii2-command-bus#yii2-command-bus)

### Widgets configurable from backend

[](#widgets-configurable-from-backend)

#### Carousel

[](#carousel)

1. Create carousel in backend
2. Use it:

```
