yii2mod/base 问题修复 & 功能扩展

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

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

yii2mod/base

Composer 安装命令:

composer create-project yii2mod/base

包简介

Base application template for Yii2

README 文档

README

Yii 2 Basic Project Template


Yii 2 Basic Application Template is a skeleton Yii 2 application best for rapidly creating small projects.

It includes all commonly used configurations that would allow you to focus on adding new features to your application.

Latest Stable Version Total Downloads License Scrutinizer Code Quality Build Status

Support us

Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

DIRECTORY STRUCTURE

  assets/             contains assets definition
  commands/           contains console commands (controllers)
  config/             contains application configurations
  controllers/        contains Web controller classes
  mail/               contains view files for e-mails
  models/             contains model classes
  runtime/            contains files generated during runtime
  tests/              contains various tests for the basic application
  vendor/             contains dependent 3rd-party packages
  views/              contains view files for the Web application
  web/                contains the entry script and Web resources

FEATURES

REQUIREMENTS

The minimum requirement by this application template that your Web server supports PHP 5.6

INSTALLATION

Installing using Composer

If you do not have Composer, follow the instructions in the Installing Yii section of the definitive guide to install it.

With Composer installed, you can then install the application using the following commands:

composer create-project --prefer-dist --stability=dev yii2mod/base application

The first command installs the composer asset plugin which allows managing bower and npm package dependencies through Composer. You only need to run this command once for all. The second command installs the yii2mod/base application in a directory named application. You can choose a different directory name if you want.

CONFIGURATION

After you install the application, you have to conduct the following steps to initialize the installed application. You only need to do these once for all.

  1. Init the application by the following command:
./init --env=Development
  1. Create a new database and adjust the components['db'] configuration in config/common-local.php accordingly.

  2. Apply migrations:

  • php yii migrate - create default tables for application
  • php yii rbac/migrate - create roles, permissions and rules
  • php yii fixture "*" - load fixtures (cms pages and users)
  1. Set document root of your web server to /path/to/application/web/ folder.

Installing using Docker

You need to have docker (1.10.0+) and docker-compose (1.6.0+) installed.

You can install the application using the following commands:

composer create-project --no-install --stability=dev yii2mod/base yii2mod-base
cd yii2mod-base
./init --env=Development
cp .env{.dist,} && cp docker-compose.override.yml{.dist,}
docker-compose up -d --build

In .env file your need to set your UID. You can get your UID by the following command in the terminal: id -u <username>

It may take some minutes to download the required docker images. When done, you need to install vendors as follows:

docker-compose exec web bash
composer install
chown -R www-data:www-data runtime web/assets vendor

After this steps, you need to update db section in the common-local.php file as follows:

<?php

$config = [
    'components' => [
        'db' => [
            'dsn' => 'mysql:host=db;dbname=yii2mod_base',
            'username' => 'docker',
            'password' => 'secret',
        ],
        'mailer' => [
            'useFileTransport' => true,
        ],
        'redis' => [
            'hostname' => 'redis',
        ],
    ],
];

return $config;

When done, you need to execute the following commands in the web container:

  • php yii migrate
  • php yii rbac/migrate
  • php yii fixture "*"

After this steps, you can access your app from http://localhost.

TESTING

Tests are located in tests directory. They are developed with Codeception PHP Testing Framework. By default there are 3 test suites:

  • unit
  • functional
  • acceptance

Running tests

  1. Create a new database and configure database connection in config/test_db.php accordingly.
  2. Execute migrations by the following command:
    • ./yii_test migrate --interactive=0 && ./yii_test rbac/migrate --interactive=0
  3. Run unit and functional tests:
bin/codecept run

The command above will execute unit and functional tests. Unit tests are testing the system components, while functional tests are for testing user interaction. Acceptance tests are disabled by default as they require additional setup since they perform testing in real browser.

Running acceptance tests

To execute acceptance tests do the following:

  1. Rename tests/acceptance.suite.yml.example to tests/acceptance.suite.yml to enable suite configuration

  2. Replace codeception/base package in composer.json with codeception/codeception to install full featured version of Codeception

  3. Update dependencies with Composer

    composer update  
    
  4. Download Selenium Server and launch it:

    java -jar ~/selenium-server-standalone-x.xx.x.jar
    
  5. Start web server:

    ./yii_test serve
    
  6. Now you can run all available tests

    # run all available tests
    bin/codecept run
    
    # run acceptance tests
    bin/codecept run acceptance
    
    # run only unit and functional tests
    bin/codecept run unit,functional
    

Code coverage support

By default, code coverage is disabled in codeception.yml configuration file, you should uncomment needed rows to be able to collect code coverage. You can run your tests and collect coverage with the following command:

#collect coverage for all tests
bin/codecept run -- --coverage-html --coverage-xml

#collect coverage only for unit tests
bin/codecept run unit -- --coverage-html --coverage-xml

#collect coverage for unit and functional tests
bin/codecept run functional,unit -- --coverage-html --coverage-xml

You can see code coverage output under the tests/_output directory.

yii2mod/base 适用场景与选型建议

yii2mod/base 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.3k 次下载、GitHub Stars 达 53, 最近一次更新时间为 2014 年 06 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 yii2mod/base 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.3k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 53
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 53
  • Watchers: 7
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-06-26