deryabinsergey / yii2-app-extended
Yii 2 Extended Project Template
Installs: 28
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.1
- rmrevin/yii2-fontawesome: ~3.7.0
- yiisoft/yii2: ~2.0.46
- yiisoft/yii2-bootstrap5: ~2.0.2
- yiisoft/yii2-symfonymailer: ~2.0.3
Requires (Dev)
- codeception/codeception: ^5.0.0
- codeception/lib-innerbrowser: ^3.0
- codeception/module-asserts: ^3.0
- codeception/module-filesystem: ^3.0
- codeception/module-webdriver: ^3.2
- codeception/module-yii2: ^1.1
- codeception/verify: ^2.2
- phpunit/phpunit: ~9.5.0
- symfony/browser-kit: ^6.0
- yiisoft/yii2-debug: ~2.1.18
- yiisoft/yii2-faker: ~2.0.0
- yiisoft/yii2-gii: ~2.2.0
README
Install via composer
composer create-project --prefer-dist deryabinsergey/yii2-app-extended:2
Benefits
This Project Template based on Advanced Template with some modifications
- add rmrevin / yii2-fontawesome Asset Bundle with Font Awesome 5
- add Bootstrap Dasboard Template to backend
- remove unique key from
user.username
. Authorization by email and password. - add RBAC implementation for users. Use in backend.
- add User CRUD to backend
- make codeception tests valid, using yii2-bootstrap5
- add some tests to backend / create user, acceptance tests for backend
- add selenium to
docker-compose.yml
and docker config atfrontend/tests/acceptance.suite.yml.example
- change php to
yiisoftware/yii2-php:8.1-apache
inDockerfile
- add config to
Dockerfile
for pretty URL - add
urlManagerFrontend
to backend config for making links from backend to frontend
Be careful in environments/dev/frontend/web/index-test.php
and environments/dev/backend/web/index-test.php
removed code to start test on Docker:
// NOTE: Make sure this file is not accessible when deployed to production
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
die('You are not allowed to access this file.');
}
All information and documentation available at Advanced Project Template.
Using RBAC
Roles and permissions defined in common/config/params.php
For adding new permission, roles and assigned permissions to roles - should create migration. For example see console/migrations/m221002_102238_initialize_rbac_roles.php
For began i make this permissions
- backend - access to backend
- userCreate - add new users in backend
- userRead - view information about existed users
- userUpdate - can update user information
- userDelete - can delete users (NB: you can soft delete existed users, just set status deleted)
and next roles
- admin has full permissions
- manager has full permissions without delete
- viewer has only read permissions
Default Roles and Permissions in tree view:
admin (role)
├─userDelete (permission)
│
└─manager (role)
├─userCreate (permission)
├─userUpdate (permission)
│
└─viever (role)
│
├─backend (permission)
└─userRead (permission)
Acceptance tests
Complete next steps to enable acceptance tests:
- copy frontend config file
frontend/tests/acceptance.suite.yml.example
tofrontend/tests/acceptance.suite.yml
and backend config filebackend/tests/acceptance.suite.yml.example
tobackend/tests/acceptance.suite.yml
- uncomment sections
selenium-event-bus
,selenium-sessions
,selenium-session-queue
,selenium-distributor
,selenium-router
,chrome
,firefox
indocker-compose.yml
- build tests:
./vendor/bin/codecept build
Run all tests: ./vendor/bin/codecept run