Yii2 REST API + Angular 12 Boilerplate (Frontend/Backend)
MIT License
This is a boilerplate project for future use. The project consists of REST API developed by Yii2 and backend/frontend developed by Angular 12 with Bootstrap 4.
The project involves:
Service | Endpoint |
---|---|
Frontend | https://yam-boilerplate.chrislee.kr/frontend |
Backend | https://yam-boilerplate.chrislee.kr/backend |
API | https://yam-boilerplate.chrislee.kr/api |
Currently, the project is not ready for production use. Following steps are suitable for configuring development environment.
To run the application, you will need docker
and docker-compose
installed.
Open the console and execute following commands.
$ git clone https://github.com/chrisleekr/yii2-angular-boilerplate.git
$ cd yii2-angular-boilerplate
$ docker-compose up -d
With docker-compose
, following containers will be configured. Please make sure port 80, 443 are available.
/api/migrations
.Once all containers are finished compiling, then open the browser.
REST API - Yii 2: http://localhost/api/debug
To make sure API is working, go to http://localhost/api/ping. You must see pong
message.
To access docker container, use following command:
docker exec -it api /bin/sh
To run code sniffer, use following command:
docker exec api composer run sniff
To run unit test, use following command:
docker exec api composer run test:unit
Backend - Angular: http://localhost/backend
Administrator username: admin
, password: 123456
Staff username: staff
, password: 123456
To see compile process, use following command:
docker logs backend --follow
To access docker container, use following command:
docker exec -it backend /bin/sh
Note that the live reloading feature has been disabled due to restriction.
Please open Developer Tool to prevent caching. The changes will be checked every 1s. Please refer
/backend/image-files/usr/local/bin/docker-entrypoint-dev.sh
.
To run unit test, use following command:
$ cd frontend
$ npm run test
Frontend - Angular: http://localhost/frontend
Username: user
, password 123456
To see compile process, use following command:
$ docker logs frontend --follow
To access docker container, use following command:
$ docker exec -it frontend /bin/sh
Note that the live reloading feature has been disabled due to restriction.
Please open Developer Tool to prevent caching. The changes will be checked every 1s. Please refer
/frontend/image-files/usr/local/bin/docker-entrypoint-dev.sh
.
To run unit test, use following command:
$ cd frontend
$ npm run test
To run E2E test, use following command:
$ cd frontend
$ npm run e2e
image-files
: contains nginx config, php.ini, composer and docker-entrypoint.sh
image-files
: contains nginx config, docker-entrypoint-dev.sh
and docker-entrypoint.sh
image-files
: contains nginx config, docker-entrypoint-dev.sh
and docker-entrypoint.sh
image-files
: contains nginx configTo run production mode, update docker-compose.yml
by changing target: build-stage
to target: production-stage
for
backend and frontend.
I changed backend/frontend code, but I cannot see changes in the browser.
As mentioned earlier, you have to open Developer Tool
to prevent cache if you are using Chrome. Or clear browser cache
and reload again.