Yii 2 Micro Service is a skeleton Yii 2 application best for developing complex Web Service with RBAC feature. it is suitable for backend mobile application.
components/ contains Web components classes
controllers/ contains Web controller classes
models/ contains model classes
modules/ contains modules classes
tests/ contains various tests for the basic application
vendor/ contains dependent 3rd-party packages
web/ contains the entry script and Web resources
console/ contains Console app to help you build model with gii console
- Clone this repo
- Running composer install / update
- Edit file /console/config/main.php for DB connection
- Run migration
./yii migrate/up 1
- Create RBAC table
./yii migrate --migrationPath=@yii/rbac/migrations/
- Run migration again
./yii migrate
- rename env-example to .env
- Edit .env to configure your environment
- Run your application
You can try this user :
username : admin
password : P4ssw0rd
OR
username : testuser
password : testuserP455
You can run it from the micro-app/ directory via:
./yii serve --docroot=./web
You can try RBAC with user login first. Then try access v1/auth-test Admin can access page : v1/auth-test, where testuser can't.
Because no web UI in this framework, we can use gii console. First one first edit console app in /console/config/main.php to connect to DB source. and run this command:
./yii gii/model --tableName=table_name --modelClass=class_name
Model Class will exist in /console/models directory. You can find detail about gii here