Yii 2.0 Advanced Application Template
</picture>
<h1 align="center">Yii 2 Advanced Project Template</h1>
<br>
Yii 2 Advanced Project Template is a skeleton Yii 2 application best for developing complex Web applications with multiple tiers.
The template includes three tiers: front end, back end, and console, each of which is a separate Yii application.
The template is designed to work in a team development environment. It supports deploying the application in different environments.
Documentation is at docs/guide/README.md.
[!IMPORTANT]
- The minimum required PHP version of Yii is PHP
8.2.
If you do not have Composer, you may install it by following the instructions at getcomposer.org.
You can then install this project template using the following commands:
composer create-project --prefer-dist yiisoft/yii2-app-advanced advanced
cd advanced…Initialize the application for the Development environment:
php init --env=Development --overwrite=AllNow you should be able to access the application through the following URLs, assuming advanced is the directory
directly under the Web root.
http://localhost/advanced/frontend/web/
http://localhost/advanced/backend/web/Build and start the containers:
docker compose up -d --buildInstall dependencies inside the container:
docker compose exec frontend composer update --prefer-dist --no-interactionInitialize the application for the Development environment:
docker compose exec frontend php /app/init --env=Development --overwrite=AllAfter running init, update the database connection in common/config/main-local.php to use the mysql
service hostname:
'db' => [
'class' => \yii\db\Connection::class,
'dsn' => 'mysql:host=mysql;dbname=yii2advanced',
'username' => 'yii2advanced',
'password' => 'secret',
'charset' => 'utf8',
],You can then access the application through the following URLs:
http://127.0.0.1:20080 (frontend)
http://127.0.0.1:21080 (backend)To run the test suite, also update common/config/test-local.php to use the mysql hostname and create the
test database:
'db' => [
'dsn' => 'mysql:host=mysql;dbname=yii2advanced_test',
],docker compose exec -T mysql mysql -uroot -pverysecret -e "CREATE DATABASE IF NOT EXISTS yii2advanced_test; GRANT ALL PRIVILEGES ON yii2advanced_test.* TO 'yii2advanced'@'%'; FLUSH PRIVILEGES;"
docker compose exec -T frontend php /app/yii_test migrate --interactive=0
docker compose exec -T frontend vendor/bin/codecept build
docker compose exec -T frontend vendor/bin/codecept runNOTES:
17.04 for development (see Performance tuning for volume mounts)~/.composer-docker/cache for Composer cachesEdit the file common/config/main-local.php with real data, for example:
return [
'components' => [
'db' => [
'class' => \yii\db\Connection::class,
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => '1234',
'charset' => 'utf8',
],
],
];When using Docker, the MySQL service is pre-configured. Update common/config/main-local.php to use:
'db' => [
'class' => \yii\db\Connection::class,
'dsn' => 'mysql:host=mysql;dbname=yii2advanced',
'username' => 'yii2advanced',
'password' => 'secret',
'charset' => 'utf8',
],Apply migrations:
php yii migrateOr with Docker:
docker compose exec frontend php /app/yii migrateNOTES:
config/ directories to customize your application as required.tests directory for information specific to application tests.Tests are located in frontend/tests, backend/tests, and common/tests directories.
They are developed with Codeception PHP Testing Framework.
Tests can be executed by running:
vendor/bin/codecept run --env php-builtinOr using the Composer script:
composer testsNo open issues yet, or sync has not completed.