Yii 2 Admin Project Template
Yii 2 Admin Project Template is a skeleton Yii 2 application best for rapidly creating admin backends projects., (*1)
Features:
* Application files in its folder.
* AdminLTE theme imported
* User schema and user login/register/profile/passwords forms.
* AdminLTE specific widgets exposed as Yii2 widgets:
* Box (with expanded/collapsed state)
* Tabs
* Select2
* GridView
* ProgressBar (vertical/horizontal)
* Popup notifications.
* ItemList (wrapper for nice AdminLTE lists)
* TimePicker
* Timeline
* TypeAhead (bootstrap version from @bower/typeahead.js), (*2)
Screenshot, (*3)
DIRECTORY STRUCTURE
bin/ contains command line utilities
app/ contains your application
assets/ contains assets definition
base/ contains base classes
commands/ contains console commands (controllers)
components/ contains various components (Menu, etc)
config/ contains application configurations
controllers/ contains Web controller classes
forms/ contains web forms
helpers/ contains application helpers
mail/ contains view files for e-mails
models/ contains model classes
tests/ contains various tests for the basic application
views/ contains view files for the Web application
widgets/ contains widgets ready to use in views
modules/ contains custom modules
vendor/ contains dependent 3rd-party packages
runtime/ contains files generated during runtime
web/ contains the entry script and Web resources
config.php local site application configuration
REQUIREMENTS
The minimum requirement by this project template that your Web server supports PHP 5.4.0., (*4)
INSTALLATION
Install composer if you have not any:, (*5)
curl -sS https://getcomposer.org/installer | php
php composer.phar global require "fxp/composer-asset-plugin"
Get the project and all dependencies:, (*6)
php composer.phar create-project skoro/yii2-admin-template yii2-admin 0.2
Answer the questions and if you need apply database migrations. And that's all.
In case if you cannot install project via composer read next chapters., (*7)
MANUAL INSTALLATION
Clone project repository:, (*8)
git clone https://github.com/skoro/yii2-admin-template.git yii2-admin
Install dependencies:, (*9)
composer.phar install
Check project requirements:, (*10)
./bin/requirements
Change to project directory and set permissions:, (*11)
chmod 777 ./runtime ./web/assets
Create your host configuration by copying sample:, (*12)
cp config-sample.php config.php
Set cookie validation key in config.php
file to some random secret string:, (*13)
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => '',
],
CONFIGURATION
Your local site configuration resides in config.php
. You can create config.php
by copying config-sample.php
., (*14)
Database
Edit the file config.php
in web root folder with real data, for example:, (*15)
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2basic',
// Or SQLite3 database (directory data must be already created and must be
// writable by webserver).
// 'dsn' => 'sqlite:@runtime/data/db.sq3',
'username' => 'root',
'password' => '1234',
'charset' => 'utf8',
];
Apply database migrations:, (*16)
./bin/yii migrate
This imports user schema into your database., (*17)
Enable debug mode
To enabled debug bar uncomment following lines in config.php
:, (*18)
define('YII_DEBUG', true);
define('YII_ENV', 'dev');
If you are on local network (not 127.0.0.1) make debug modules happy with
following lines:, (*19)
'modules' => [
'debug' => [
'allowedIPs' => ['192.168.1.*'],
],
'gii' => [
'allowedIPs' => ['192.168.1.*'],
],
],
These lines enable debug
and gii
modules for clients from 192.168.1.*
subnetwork., (*20)
TESTING
After application has been installed and configured it's time to test it.
First of all, create user via command yii
line utility:, (*21)
./bin/yii user/create "User name" mail@address.com
Assign the newly created user to the Administrators group:, (*22)
./bin/yii rbac/assign mail@address Administrator
Then launch local web server:, (*23)
./bin/yii serve
Now you can access the application through the following URL and try to login:, (*24)
http://localhost:8080