-
If you do not have Composer, you may install it by following the instructions at getcomposer.org.
-
Install composer-asset-plugin needed for yii assets management
composer global require "fxp/composer-asset-plugin"
- Install NPM or Yarn to build frontend scripts
- [NPM] (https://docs.npmjs.com/getting-started/installing-node)
- Yarn (https://yarnpkg.com/en/docs/install)
https://github.com/ankyestudio/aktracking/archive/master.zip
git clone https://github.com/ankyestudio/aktracking.git
composer install
The minimum requirement by this application template that your Web server supports PHP 5.5.0. Required PHP extensions:
- intl
- gd
- mcrypt
- com_dotnet (for Windows)
-
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=127.0.0.1;port=3306;dbname=yii2-starter-kit DB_USERNAME = user DB_PASSWORD = password
- Set application canonical urls
FRONTEND_HOST_INFO = http://yii2-starter-kit.dev BACKEND_HOST_INFO = http://backend.yii2-starter-kit.dev STORAGE_HOST_INFP = http://storage.yii2-starter-kit.dev
-
Run in command line
php console/yii app/setup
npm install
npm run build
- Copy
docker/vhost.conf
to your nginx config directory - Change it to fit your environment
- Follow docker install instruction to install docker
- Add
127.0.0.1 yii2-starter-kit.dev backend.yii2-starter-kit.dev storage.yii2-starter-kit.dev
* to yourhosts
file - Copy
.env.dist
to.env
in the project root - Run
docker-compose build
- Run
docker-compose up -d
- Log into the app container via
docker-compose exec app bash
- Install composer per instuctions available at Composer
- Run
php composer.phar global require "fxp/composer-asset-plugin"
andcomposer install --profile --prefer-dist -o -v
- If asked for a token aquire one from your github account.
- Setup application with
php ./console/yii app/setup --interactive=0
- Exit the app container by using
exit
- That's all - your application is accessible on http://yii2-starter-kit.dev
-
- docker host IP address may vary on Windows and MacOS systems
PS Also you can use bash inside application container. To do so run docker-compose exec app bash
- How do i run yii console commands from outside a container?
docker-compose exec app console/yii help
docker-compose exec app console/yii migrate
docker-compose exec app console/yii rbac-migrate
- How to connect to the application database with my workbench, navicat etc?
MySQL is available on
yii2-starter-kit.dev
, port3306
. User -root
, password -root
If you want, you can use bundled Vagrant instead of installing app to your local machine.
- Install Vagrant
- Copy files from
docs/vagrant-files
to application root - Copy
./vagrant/vagrant.yml.dist
to./vagrant/vagrant.yml
- Create GitHub personal API token
- Edit values as desired including adding the GitHub personal API token to
./vagrant/vagrant.yml
- Run:
vagrant plugin install vagrant-hostmanager
vagrant up
That`s all. After provision application will be accessible on http://yii2-starter-kit.dev
Login: admin
Password: admin
Adjust settings in .env
file
FRONTEND_BASE_URL = /
BACKEND_BASE_URL = /backend/web
STORAGE_BASE_URL = /storage/web
Adjust settings in backend/config/web.php
file
...
'components'=>[
...
'request' => [
'baseUrl' => '/admin',
...
Adjust settings in frontend/config/web.php
file
...
'components'=>[
...
'request' => [
'baseUrl' => '',
...
This is an example single domain config for apache
<VirtualHost *:80>
ServerName yii2-starter-kit.dev
RewriteEngine on
# the main rewrite rule for the frontend application
RewriteCond %{HTTP_HOST} ^yii2-starter-kit.dev$ [NC]
RewriteCond %{REQUEST_URI} !^/(backend/web|storage/web)
RewriteRule !^/frontend/web /frontend/web%{REQUEST_URI} [L]
# redirect to the page without a trailing slash (uncomment if necessary)
#RewriteCond %{REQUEST_URI} ^/backend/$
#RewriteRule ^(/backend)/ $1 [L,R=301]
# disable the trailing slash redirect
RewriteCond %{REQUEST_URI} ^/backend$
RewriteRule ^/backend /backend/web/index.php [L]
# the main rewrite rule for the backend application
RewriteCond %{REQUEST_URI} ^/backend
RewriteRule ^/backend(.*) /backend/web$1 [L]
DocumentRoot /your/path/to/yii2-starter-kit
<Directory />
Options FollowSymLinks
AllowOverride None
AddDefaultCharset utf-8
</Directory>
<Directory "/your/path/to/yii2-starter-kit/frontend/web">
RewriteEngine on
# if a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward the request to index.php
RewriteRule . index.php
Require all granted
</Directory>
<Directory "/your/path/to/yii2-starter-kit/backend/web">
RewriteEngine on
# if a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward the request to index.php
RewriteRule . index.php
Require all granted
</Directory>
<Directory "/your/path/to/yii2-starter-kit/storage/web">
RewriteEngine on
# if a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward the request to index.php
RewriteRule . index.php
Require all granted
</Directory>
<FilesMatch \.(htaccess|htpasswd|svn|git)>
Require all denied
</FilesMatch>
</VirtualHost>
This is an example single domain config for nginx
server {
listen 80;
root /var/www;
index index.php index.html;
server_name yii2-starter-kit.dev;
charset utf-8;
# location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|pdf|ppt|txt|bmp|rtf|js)$ {
# access_log off;
# expires max;
# }
location / {
root /var/www/frontend/web;
try_files $uri /frontend/web/index.php?$args;
}
location /backend {
try_files $uri /backend/index.php?$args;
}
# storage access
location /storage {
try_files $uri /storage/web/index.php?$args;
}
client_max_body_size 32m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php-fpm;
fastcgi_index index.php;
include fastcgi_params;
## Cache
# fastcgi_pass_header Cookie; # fill cookie valiables, $cookie_phpsessid for exmaple
# fastcgi_ignore_headers Cache-Control Expires Set-Cookie; # Use it with caution because it is cause SEO problems
# fastcgi_cache_key "$request_method|$server_addr:$server_port$request_uri|$cookie_phpsessid"; # generating unique key
# fastcgi_cache fastcgi_cache; # use fastcgi_cache keys_zone
# fastcgi_cache_path /tmp/nginx/ levels=1:2 keys_zone=fastcgi_cache:16m max_size=256m inactive=1d;
# fastcgi_temp_path /tmp/nginx/temp 1 2; # temp files folder
# fastcgi_cache_use_stale updating error timeout invalid_header http_500; # show cached page if error (even if it is outdated)
# fastcgi_cache_valid 200 404 10s; # cache lifetime for 200 404;
# or fastcgi_cache_valid any 10s; # use it if you want to cache any responses
}
}
## PHP-FPM Servers ##
upstream php-fpm {
server app:9000;
}
- There is a VirtualBox bug related to sendfile that can lead to corrupted files, if not turned-off
Uncomment this in your nginx config if you are using Vagrant:
sendfile off;