yiisoft/yii2-app-advanced 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yiisoft/yii2-app-advanced

Composer 安装命令:

composer create-project yiisoft/yii2-app-advanced

包简介

Yii 2 Advanced Project Template

README 文档

README

Yii Framework

Yii 2 Advanced Project Template


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.

Latest Stable Version Total Downloads build Static Analysis

Docker

Apache

REQUIREMENTS

Important

  • The minimum required PHP version of Yii is PHP 8.2.

Install via Composer

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

Frontend

Web Application Advanced - Frontend

Backend

Web Application Advanced - Backend

DIRECTORY STRUCTURE

common
    config/              contains shared configurations
    mail/                contains view files for e-mails
    models/              contains model classes used in both backend and frontend
    tests/               contains tests for common classes
console
    config/              contains console configurations
    controllers/         contains console controllers (commands)
    migrations/          contains database migrations
    models/              contains console-specific model classes
    runtime/             contains files generated during runtime
backend
    assets/              contains application assets such as JavaScript and CSS
    config/              contains backend configurations
    controllers/         contains Web controller classes
    models/              contains backend-specific model classes
    runtime/             contains files generated during runtime
    tests/               contains tests for backend application
    views/               contains view files for the Web application
    web/                 contains the entry script and Web resources
frontend
    assets/              contains application assets such as JavaScript and CSS
    config/              contains frontend configurations
    controllers/         contains Web controller classes
    models/              contains frontend-specific model classes
    runtime/             contains files generated during runtime
    tests/               contains tests for frontend application
    views/               contains view files for the Web application
    web/                 contains the entry script and Web resources
    widgets/             contains frontend widgets
vendor/                  contains dependent 3rd-party packages
environments/            contains environment-based overrides

Initialize the application for the Development environment:

php init --env=Development --overwrite=All

Now 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/

Install with Docker

Build and start the containers:

docker compose up -d --build

Install dependencies inside the container:

docker compose exec frontend composer update --prefer-dist --no-interaction

Initialize the application for the Development environment:

docker compose exec frontend php /app/init --env=Development --overwrite=All

After 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 run

NOTES:

  • Minimum required Docker engine version 17.04 for development (see Performance tuning for volume mounts)
  • The default configuration uses a host-volume in your home directory ~/.composer-docker/cache for Composer caches

CONFIGURATION

Database

Edit 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 migrate

Or with Docker:

docker compose exec frontend php /app/yii migrate

NOTES:

  • Yii won't create the database for you, this has to be done manually before you can access it. When using Docker, the MySQL service creates the database automatically.
  • Check and edit the other files in the config/ directories to customize your application as required.
  • Refer to the README in the tests directory for information specific to application tests.

TESTING

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-builtin

Or using the Composer script:

composer tests

Support the project

Open Collective

Follow updates

Official website Follow on X Telegram Slack

License

License

yiisoft/yii2-app-advanced 适用场景与选型建议

yiisoft/yii2-app-advanced 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 961.32k 次下载、GitHub Stars 达 1.67k, 最近一次更新时间为 2013 年 05 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「framework」 「advanced」 「yii2」 「project template」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 yiisoft/yii2-app-advanced 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 yiisoft/yii2-app-advanced 我们能提供哪些服务?
定制开发 / 二次开发

基于 yiisoft/yii2-app-advanced 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 961.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1697
  • 点击次数: 23
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 1669
  • Watchers: 166
  • Forks: 1254
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2013-05-24