If you do not have Composer, you may install it by following the instructions at getcomposer.org.
It uses asset-packagist for managing bower and npm package dependencies through Composer. Also you can use asset-plugin, as in earlier versions, but it works slowly.
You can install this application template with composer
using the following command:
composer create-project --prefer-dist --stability=dev beaten-sect0r/yii2-core
https://github.com/Beaten-Sect0r/yii2-core/archive/master.zip
git clone https://github.com/Beaten-Sect0r/yii2-core.git
composer install --prefer-dist
The minimum requirement by this project template is that your Web server supports PHP 5.4.0.
-
Copy
.env.dist
to.env
in the project root. -
Adjust settings in
.env
file- Set debug mode and your current environment
YII_DEBUG = true YII_ENV = dev
- Set DB configuration
DB_DSN = mysql:host=localhost;port=3306;dbname=yii2-core DB_USERNAME = user DB_PASSWORD = password
- Set application canonical urls
FRONTEND_URL = http://yii2-core.loc BACKEND_URL = http://backend.yii2-core.loc STORAGE_URL = http://storage.yii2-core.loc
-
Run in command line
php yii app/setup
administrator
role account
Login: Administrator
Password: passwd
Or configure your web server with three different web roots:
- yii2-core.loc => /path/to/yii2-core/frontend/web
- backend.yii2-core.loc => /path/to/yii2-core/backend/web
- storage.yii2-core.loc => /path/to/yii2-core/storage
Adjust settings in .env
file
FRONTEND_URL = http://yii2-core.loc
BACKEND_URL = http://yii2-core.loc/backend
STORAGE_URL = http://yii2-core.loc/storage
Adjust settings in backend/config/main.php
file
...
'components'=>[
...
'request' => [
'baseUrl' => '/backend',
...
Adjust settings in frontend/config/main.php
file
...
'components'=>[
...
'request' => [
'baseUrl' => '',
...
Single domain .htaccess for apache
# Set the default charset.
AddDefaultCharset UTF-8
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Enable symlinks
Options +FollowSymlinks
# Enable mod_rewrite
RewriteEngine On
# Backend redirect
RewriteCond %{REQUEST_URI} ^/backend
RewriteRule ^backend/(.*)$ backend/web/$1 [L]
# Storage redirect
RewriteCond %{REQUEST_URI} ^/storage
RewriteRule ^storage/(.*)$ storage/$1 [L]
# Frontend redirect
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteRule ^(.*)$ frontend/web/$1
https://www.youtube.com/watch?v=XAC5joagA70
This way is the easiest but long (~20 min).
This installation way doesn't require pre-installed software (such as web-server, PHP, MySQL etc.) - just do next steps!
-
Install VirtualBox
-
Install Vagrant
-
Create GitHub personal API token
-
Copy
vagrant-local.example.yml
tovagrant-local.yml
-
Place your GitHub personal API token to
vagrant-local.yml
-
Run commands:
cd yii2-core vagrant plugin install vagrant-hostmanager vagrant up
That's all. You just need to wait for completion! After that you can access project locally by URLs:
- frontend: http://yii2-core.loc
- backend: http://backend.yii2-core.loc
- storage: http://storage.yii2-core.loc
- phpmyadmin: http://pma.yii2-core.loc