- Before you begin
- Manual installation
- Server configuration
- Hosting installation
- Docker installation
- Vagrant installation
- Single domain installtion
- Demo users
- Important-notes
-
If you do not have Composer, you may install it by following the instructions at getcomposer.org.
-
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/shirase/yii2-starter-kit/archive/master.zip
git clone https://github.com/shirase/yii2-starter-kit.git
composer install
You can install this application template with composer
using the following command:
composer create-project --prefer-dist --stability=dev shirase/yii2-starter-kit
The minimum requirement by this application template that your Web server supports PHP 5.6.0. Required PHP extensions:
- intl
- gd
- mcrypt
- zip
- 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 urls (for single domain configuration)
FRONTEND_URL = / BACKEND_URL = /admin STORAGE_URL = /storage FRONTEND_HOST = http://yii2-starter-kit.dev BACKEND_HOST = http://yii2-starter-kit.dev STORAGE_HOST = http://yii2-starter-kit.dev
- Set application urls (for multi domain configuration)
FRONTEND_URL = BACKEND_URL = STORAGE_URL = FRONTEND_HOST = http://yii2-starter-kit.dev BACKEND_HOST = http://backend.yii2-starter-kit.dev STORAGE_HOST = http://storage.yii2-starter-kit.dev
-
Run in command line
php console/yii app/setup
npm install
npm run build
- Use project root as apache webroot directory
- Use
docker/nginx/vhost.conf
as example
- Add rewrites to static location
rewrite ^/admin(.*)$ /backend/web$1 break;
rewrite ^(.*)$ /frontend/web$1 break;
- Remove
Assets
section from.gitignore
- Build assets, run
npm run build
(install npm before) - Change
style.scss
tostyle.css
infrontend/assets/FrontendAsset.php
andbackend/assets/BackendAsset.php
files - Build bundle, run
./bin/bundle.sh
(Linux) orbin\bundle.bat
(Windows) - Copy all files to hosting, outside of webroot directory,
app
for example. Usegit
if you can.
- Rename or remove current webroot directory
- Make symlink
frontend/web
topublic_html
- Make symlink
backend/web
topublic_html/admin
- Make symlink
storage/web
topublic_html/storage
- Upload
symlink.php
to webroot directory, run it likehttp://example.com/symlink.php
- Delete
symlink.php
- Change paths in
index.php
files - Upload
frontend/web
files topublic_html
- Upload
backend/web
files topublic_html/admin
- Upload
storage/web
files topublic_html/storage
- Follow docker install instruction to install docker
- Copy
.env.dist
to.env
in the project root - Change
.env
DB_DSN host to "db" - 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
composer 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
- Run
npm install
- Exit the app container by using
exit
- That's all - your application is accessible on http://127.0.0.1:81
-
- 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: webmaster
Password: webmaster
Login: manager
Password: manager
Login: user
Password: user
- 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;