writ3it/cs_modular-monolith
Composer 安装命令:
composer require writ3it/cs_modular-monolith
包简介
PHPCS Standards for modular monoliths.
README 文档
README
PHPCS Standards for modular monolith. This package is under development.
Why?
There are three good reasons.
Reason 1.
PHP doesn't support Java-like packages. This standard is a liberal version of this feature (you can use or not). You can force standard while collaborating through CI/CD process.
Reason 2.
Monolith is very popular architecture, but it's a hell for developers. Monolithic application (sooner or later) is often called "legacy code". The alternative - isolation provided by composer package feature often is too strong. Language-level package system offers more flexible module implementation.
Reason 3.
Deptrac which has a most similar feature isn't integrated with Phpstorm. PHP_CodeSniffer is.
Required dependencies
- squizlabs/php_codesniffer package
- php >= 5.6
- ext-simplexml
Getting started
Step 1. Install standard in your project
$ composer require --dev writ3it/cs_modular-monolith
Step 2. Create or extend your phpcs.xml.dist
If you have another ruleset file, add the following lines:
<config name="installed_paths" value="vendor/writ3it/cs_modular-monolith"/> <rule ref="ModularMonolith"> <properties> <property name="modules_definitions_path" value="modules.xml"/> </properties> </rule>
Full example file (Symfony):
<?xml version="1.0" encoding="UTF-8"?> <ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> <arg name="basepath" value="."/> <arg name="cache" value=".phpcs-cache"/> <arg name="colors"/> <arg name="extensions" value="php"/> <rule ref="PSR2"/> <rule ref="PSR12"/> <file>bin/</file> <file>config/</file> <file>public/</file> <file>src/</file> <file>tests/</file> <config name="installed_paths" value="vendor/writ3it/cs_modular-monolith"/> <rule ref="ModularMonolith"> <properties> <property name="modules_definitions_path" value="modules.xml"/> </properties> </rule> </ruleset>
Step 3. Create modules.xml
modules.xml describes your modules hierarchy and limits module interface to the public source code.
Example file:
<?xml version='1.0' encoding='UTF-8'?> <modules> <module name="ModuleOne"> <source namespace="\App\ModuleOne\"/> <submodules> <module name="NestedModule"> <source namespace="\App\ModuleOne\NestedModule\"/> <public> <source namespace="\App\ModuleOne\NestedModule\Port\"/> </public> </module> </submodules> </module> <module name="ModuleTwo"> <source namespace="\App\ModuleTwo\"/> </module> </modules>
Step 4. (CLI) Test your code!
Execute in your project root directory:
./vendor/bin/phpcs
Step 4. (PhpStorm) Test your code on-the-fly!
See instructions from JetBrains.
TODO
- Validation of modules boundaries. (MVP, 1.0)
- Validation of nested modules boundaries.(MVP, 1.0)
- Possible to define public module interface that is accessible through boundaries. (MVP, 1.0)
- Usability improvements. (MVP, 1.0)
- Tests. (1.0)
- Documentation. (1.0)
- Configuration validation. (future)
- Drawing of modules dependency net. (possibly)
- Validation of length of dependency paths. (possibly)
- Validation of dependency cycles. (possibly)
Contributing
Before first release contributing is not possible but feel free to make issues.
License
MIT License, see details.
writ3it/cs_modular-monolith 适用场景与选型建议
writ3it/cs_modular-monolith 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 writ3it/cs_modular-monolith 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 writ3it/cs_modular-monolith 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-30
