aura/project-kernel
Composer 安装命令:
composer require aura/project-kernel
包简介
The shared kernel files for an Aura project.
README 文档
README
This kernel package exists as a base for Aura.Cli_Kernel, Aura.Web_Kernel, and other future kernel types.
Foreword
Requirements
This kernel requires PHP 7.2 or later; we recommend using the latest available version of PHP as a matter of principle. If you are interested in using this package for older PHP versions, use version 2.x for PHP 5.3+.
Unlike Aura library packages, this kernel package has userland dependencies, which themselves may have other dependencies:
Installation
This kernel is installable and autoloadable via Composer with the following
require element in your composer.json file:
"require": {
"aura/project-kernel": "dev-develop-2"
}
Alternatively, download or clone this repository, then require or include its autoload.php file.
Tests
This kernel has 100% code coverage with PHPUnit. To run the unit tests at the command line, issue composer install and then composer test at the package root. This requires Composer to be available as composer.
PSR Compliance
This kernel attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request.
Community
To ask questions, provide feedback, or otherwise communicate with the Aura community, please join our Google Group, follow @auraphp on Twitter, or chat with us on #auraphp on Freenode.
Services
This package defines the following services in the Container:
aura/project-kernel:logger: an instance of Psr\Log\NullLogger
Note that service definitions set at the kernel level may be reset at the project level.
Configuration
Although configuration is a project-level concern, each Aura kernel and project handles it in the same way. Thus, we provide config documentation here to reduce repetition.
N.b.: The examples throughout this document are for Aura\Web_Project; replace that with Aura\Cli_Project or Aura\Framework_Project as needed.
Setting The Config Mode
Set the configuration mode using $_ENV['AURA_CONFIG_MODE'], either via a server variable or the project-level config/_env.php file. Each Aura project comes with dev (local development), test (shared testing/staging), and prod (production) modes pre-defined.
Config File Location
Project-level configuration files are located in the project-level config/ directory. Each configuration file is a class that extends Aura\Di\Config, and represents a configuration mode. Each configuration class has two methods:
-
define(), which allows you to define params, setters, and services in the project Container; and -
modify(), which allows you to pull objects out of the Container for programmatic modification. (This happens after the Container is locked, so you cannot add new services or change params and setters here.)
The two-stage configuration system loads all the configuration classes in order by library, kernel, and project, then runs all the define() methods, locks the container, and finally runs all the modify() methods.
Mapping Config Modes To Classes
The config modes are mapped to their related config class files via the project-level composer.json file in the extra:aura:config block. The entry key is the config mode, and the entry value is the class to use for that mode.
{
"autoload": {
"psr-0": {
"": "src/"
},
"psr-4": {
"Aura\\Web_Project\\_Config\\": "config/"
}
},
"extra": {
"aura": {
"type": "project",
"config": {
"common": "Aura\\Web_Project\\_Config\\Common",
"dev": "Aura\\Web_Project\\_Config\\Dev",
"test": "Aura\\Web_Project\\_Config\\Test",
"prod": "Aura\\Web_Project\\_Config\\Prod"
}
}
}
}
Config classes are autoloaded via a PSR-4 entry for that project namespace.
The "common" config class is always loaded regardless of the actual config mode. For example, if the config mode is dev, first the Common class is loaded, and then the Dev class.
Changing Config Settings
First, open the config file for the related config mode. To change configuration params, setters, and services, edit the define() method. To programmatically change a service after all definitions are complete, edit the modify() method.
Adding A Config Mode
If you want to add a new configuration mode, say qa, you need to do three things.
First, create a config class for it in config/:
<?php namespace Aura\Web_Project\_Config; use Aura\Di\Config; use Aura\Di\Container; class Qa extends Config { public function define(Container $di) { // define params, setters, and services here } public function modify(Container $di) { // modify existing services here } } ?>
Next, edit the project-level composer.json file to add the new config mode with its related class:
{
"extra": {
"aura": {
"type": "project",
"config": {
"common": "Aura\\Web_Project\\_Config\\Common",
"dev": "Aura\\Web_Project\\_Config\\Dev",
"test": "Aura\\Web_Project\\_Config\\Test",
"prod": "Aura\\Web_Project\\_Config\\Prod",
"qa": "Aura\\Web_Project\\_Config\\Qa"
}
}
}
}
Finally, run composer update so that Composer makes the necessary changes to the autoloader system.
aura/project-kernel 适用场景与选型建议
aura/project-kernel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 85.96k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2013 年 11 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「project」 「kernel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aura/project-kernel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aura/project-kernel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aura/project-kernel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
SDK kernel for php
淘宝 SDK 封装, 调用简单、语义化增强。支持 Laravel/Lumen。
PhpPlaisio: Kernel
Task system for APPUI
Pollen Solutions - Kernel Component - Basic tools for building a web application based on the Pollen Solutions component suite.
Pollen Solutions - Wordpress Kernel Component - Basic tools for building a web application based on Wordpress and the Pollen Solutions component suite.
统计信息
- 总下载量: 85.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 8
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2013-11-21