keiwen/cacofony
Composer 安装命令:
composer require keiwen/cacofony
包简介
Custom Application Code Overlay for symfony
README 文档
README
Custom Application Code Overlay for Symfony framework
Consolidation completed for Symfony 6.4
Controller
- Parent controller 'AppController' is provided
- AppController can automatically dump template parameters on dev: when modifying template, you can see every available parameters
- AppController can automatically retrieve template
(in "{controllerName}/{functionName}.html.twig") by using
return renderTemplate([]) - AppController can redirect with cookies already defined. Methods are added to redirect to referer or to self route.
Controller use a specific Request object (extending standard one), and should be declared in public/index file:
//use Symfony\Component\HttpFoundation\Request
use Keiwen\Cacofony\Http\Request
Declare its use in kernel if needed
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
Restrict to Role
This attribute could be used to check user role. Could be on a single action or for a whole controller.
#[RestrictToRole(roles: "admin")]
class TestController extends DefaultController
In this example, system will check if user has 'ROLE_ADMIN' role. If not, an AccessDeniedException is raised. Value in attribute don't need to be uppercase or have the 'role_' prefix.
Template Param
This attribute could be used for 'constants' given to templates. It could be defined on a single action, or for the full controller
#[TemplateParameter(name: "section", value: "test")
class TestController extends DefaultController
In this example, all actions in this controller will automatically return a 'section' parameter, with value 'test'
Translation
For translations purpose, you can set a specific locale (default 'transCode') to display translations code instead of actual translated strings. Useful when working on translations from running application.
Twig
Filters
labeladd ':' at the end of your text. Depending on locale, it can add non-breakable space (as in french)str_limitto limit displayed string to given length, ending with '...' by defaultucfirstswitch first letter to uppercase
Methods
getRoute()returns route namehasRole('user')check if current user has specified role. Value don't need to be uppercase or have the 'role_' prefix.
EntityRegistry
Can save, remove, detach or copy an entity or a list of entities. Each methods include an optional commit parameter (default true). In controller:
$this->getEntityRegistry()->saveObject($entity);
keiwen/cacofony 适用场景与选型建议
keiwen/cacofony 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 68 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 keiwen/cacofony 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 keiwen/cacofony 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 68
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2019-06-10