Friday, May 05 2017
After long time we have posted article about installing theme of AdminLTE for backend in Yii2 Framework. Adminlte theme integration in Yii2 useful for beginners.
If you don’t have composer in your machine, download composer from Composer-Setup.exe. for Windows users.
For linux or Mac osx users please do following commands
curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer
Demonstration Video:
Installing Yii:
With Composer installed, execute following commands for installing basic template of Yii2
composer global require "fxp/composer-asset-plugin:^1.3.1" composer create-project --prefer-dist yiisoft/yii2-app-basic basic
Installtion : Yii2 – advanced template:
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced yii2-app
During installation it needs access token key from Github.
Once installation complete then execute below commands to initialize the setup.
C:\wamp\www\yii2-app>php init
You can select the environment type from the given options:
Which environment do you want the application to be initialized in? [0] Development [1] Production Your choice [0-1, or "q" to quit]
After installation, backend looks like
In frontend looks like
http://localhost/devel/yii2-app/frontend/web/ // Front end http://localhost/devel/yii2-app/backend/web/index.php?r=site%2Flogin // Back end
Customize your login url of admin panel and frontend url.
Open the httpd-vhosts.conf file. in xampp\apache\conf\extra\
Added below codes onto that file
<VirtualHost *:80> DocumentRoot "F:/xampp/htdocs/devel/yii2-app/frontend/web" ServerName www.yii2.dev <Directory "F:/xampp/htdocs/devel/yii2-app/frontend/web"> Options Indexes FollowSymLinks ExecCGI Includes Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost *:80> DocumentRoot "F:/xampp/htdocs/devel/yii2-app/backend/web" ServerName admin.yii2.dev <Directory "F:/xampp/htdocs/devel/yii2-app/backend/web"> Options Indexes FollowSymLinks ExecCGI Includes Order allow,deny Allow from all </Directory> </VirtualHost>
Open this directory
C:\Windows\System32\drivers\etc\
and update hosts file with below lines
127.0.0.3 www.yii2.dev 127.0.0.4 admin.yii2.dev
After that you can login with above urls for your admin panel and front end.
To install AdminLTE v2 run:
php composer.phar require dmstr/yii2-adminlte-asset "2.*"
To install AdminLTE v1 run:
If you don’t have composer.phar files,
Execute the composer commands from getcomposer.org
Added below lines in your backend > config > main-local.php with inside the components array.
'components' => [ 'view' => [ 'theme' => [ 'pathMap' => [ '@app/views' => '@vendor/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app' ], ], ], ],
OUTPUT: