prestashop/module-lib-service-container
Composer 安装命令:
composer require prestashop/module-lib-service-container
包简介
Service container to use on prestashop modules
README 文档
README
This repository includes the service container from Symfony that you can use in your PrestaShop Module.
Pre-requisites
You should install this library only on a PrestaShop environment and with PHP 5.6.0 minimum.
Installation
# PrestaShop 1.7+ composer require prestashop/module-lib-service-container # PrestaShop 1.6 composer require prestashop/module-lib-service-container composer require symfony/config:^3.4 symfony/dependency-injection:^3.4 symfony/expression-language:^3.4 symfony/yaml:^3.4
When this project is successfully added to your dependencies, you can add the new ServiceContainer to your module and use it. PrestaShop runs with Symfony components from version 1.7, so dependancies are not required anymore here. I you plan to run your module on PrestaShop, Symfony dependencies must be required separately.
Usage
To use this library, it's simple :
- First, declare your new service Container in your root module PHP file (like mymodule.php at your root project folder) :
/**
* @var ServiceContainer
*/
private $serviceContainer;
- And instantiate it in the constructor with the module name and its local path :
$this->serviceContainer = new ServiceContainer($this->name, $this->getLocalPath());
- You can add a new function on your root module PHP file, like getService, to retrieve your service name in the new service container :
/**
* @param string $serviceName
*
* @return mixed
*/
public function getService($serviceName)
{
return $this->serviceContainer->getService($serviceName);
}
- Then, you have to declare your service in the services.yml file. You must declare your services in the config/ folder. From Symfony 4, services must be explicitely declared as public to be loaded with the method
getService();
We split the services in two folders in the config : /front and /admin folders. So the tree should be like :
/mymodule
/config
/front
services.yml
/admin
services.yml
common.yml
- Of course, you can include a common file, with common services that are use in front and admin project by an import in the services.yml file :
imports:
- { resource: ../common.yml }
Now you can add your services in the services.yml like you were in a Symfony project ;)
prestashop/module-lib-service-container 适用场景与选型建议
prestashop/module-lib-service-container 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 183.82k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2020 年 09 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「composer」 「modules」 「prestashop」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 prestashop/module-lib-service-container 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 prestashop/module-lib-service-container 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 prestashop/module-lib-service-container 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This is Paymorrow module for OXID eShop.
Analysis module for finding problematical shop data.
yii2 swiper slider
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
An interactive tour through the TYPO3 backend.
统计信息
- 总下载量: 183.82k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 28
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: AFL-3.0
- 更新时间: 2020-09-08