承接 monarc/core 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

monarc/core

Composer 安装命令:

composer require monarc/core

包简介

Core for monarc/monarc application

README 文档

README

Development notes concerning the following:

  • Entity
  • Table
  • Controller
  • Service
  • Container configuration in module.config.php
  • Tests Coverage

Entity

Creation of entities should be performed as a simple object instantiation, e.g.

$myEntityClass = (new MyEntityClass())
    ->setName('name')
    ->setCode('codde');

The entity should have a single responsibility and do not perform any database related operations itself.

Note! The AbstractEntity inheritance is going to be removed and the entities filters methods cleaned uo.

For generating migrating file & migrate DB with adding/deleting/changing column:

php ./vendor/bin/doctrine-module migrations:diff
php ./vendor/bin/doctrine-module migrations:migrate

Entity Table

Implementation of table (repositories) classes are done in Model/Table folder and extend AbstractTable.

In the table constructor there is mandatory to pass an entity class name that the table is responsible to manage, e.g.

public function __construct(EntityManager $entityManager)
{
    parent::__construct($entityManager, \MyEntityNamespace\MyEntityClass::class);
}

The table methods, responsible for fetching data from the DB should start from findBy prefix. AbstractTable has methods, which help with the basic entities operations.

  • save
  • remove
  • and so on.

In the module config file there is required to define an way of the table class creation. In most of the cases it works well with Laminas\Di\Container\AutowireFactory:

\MyEntityNamespace\MyEntityClass::class => AutowireFactory::class,

Controller

One of the controller can be extend when particular ones created:

  • Laminas\Mvc\Controller\AbstractRestfulController
  • Monarc\Core\Controller\Handler\AbstractRestfulControllerRequestHandler

There is a trait helper class that can be used in the controllers to help with the output rendering: Monarc\Core\Controller\Handler\ControllerRequestResponseHandlerTrait

Restful application methods to be defined:

  • getList()
  • get($id)
  • create($data)
  • update($id, $data)
  • delete($id)

In module.config.php, controllers are usually defined in the configuration like:

ControllerNameSpace\MyController::class => AutowireFactory::class,

Service

Note New created services classes should not extend AbstractService, is going to be be removed in the future.

In the module config file the services container looks like:

ServiceNamescpace\MyService::class => Laminas\Di\Container\AutowireFactory::class,

or, in case if config needs to be injected:

ServiceNamescpace\MyService::class => Laminas\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory::class,

Input Formatters

The input formatters classes aim to perform the [GET] requests data filtering, validating and transforming into a format that can be used directly to prepare the database queries. The formatters classes are enriched with possibilities of handling and preparing the data for search by text, filter by params, ordering and pagination.

Tha basic classes are InputFormatter\AbstractInputFormatter, InputFormatter\FormattedInputParams. The instantiated objects inherited the basic classes are used in the Controllers and the formatted results are passed to the services and to the table classes methods. The tables' classes, inherited the Table\AbstractTable have a certain method findByParams where the FormattedInputParams object is accepted and processed to generate the query.

The trait's method Controller\Handler\ControllerRequestResponseHandlerTrait::getFormattedInputParams helps in the process.

Validators

The validators classes are responsible to validate the post, put and patch requests' data. Every child class of Validator\InputValidator\AbstractInputValidator have to describe a set rules that are used to validate the incoming data.
The validated data can be obtained with use of the methods getValidData, getValidDataSets if isValid result is true.

The trait's method Controller\Handler\ControllerRequestResponseHandlerTrait::validatePostParams helps in the process. It can also handle the batch data requests, that are used for the import operations.

Tests Coverage

The implementation is partially done on MonarcAppFO side, because integration and functional tests should cover the both Core and FrontOffice modules of the MONARC application.

Unit tests can be implemented at a particular projects side.

We might move from the current Core/FrontOffice modules approach to a libraries/responsibility specific and the tests will be moved as well.

License

This software is licensed under GNU Affero General Public License version 3

For more information, the list of authors and contributors is available.

Disclaimer: This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

monarc/core 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 5
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: AGPL-3.0-or-later
  • 更新时间: 2019-08-26