alvarium/cake-oc
Composer 安装命令:
composer require alvarium/cake-oc
包简介
OCClient plugin for CakePHP
README 文档
README
A CakePHP 3.X plugin for the OpenComponents PHP Client
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require alvarium/cake-oc
Configuration
After that, load the plugin in your bootstrap.php file:
Plugin::load('Alvarium/OCClient', ['bootstrap' => true]);
Create a file named occlient.php in your config folder defining your
open-components registry endpoint:
<?php return [ 'OCClient' => [ 'serverRendering' => 'https://registry.your-company.io/', ] ];
Then, load the component + the helper in the controller(s) where you want the plugin to be used:
<?php namespace App; use Cake\Event\Event; class PostsController extends AppController { public function initialize() { parent::initialize(); $this->loadComponent('Alvarium/OCClient.Client'); } public function beforeRender(Event $event) { parent::beforeRender($event); $this->viewBuilder()->helpers([ 'Alvarium/OCClient.OC', ]); } }
Usage
After all configuration has been done, and having both component and helper loaded,
to load your opencomponents scripts in your pages you just need to define the
components using setComponents in your controller method:
<?php namespace App; // [...] class PostsController extends AppController { // [...] public function index() { $this->Client->setComponents([ [ 'name' => 'your-awesome-component', 'parameters' => [ 'comp1_selector' => '#awesome-component', 'key' => 'value', 'key2' => 'value2', ], ], [ 'name' => 'another-awesome-component', 'parameters' => [ 'comp2_selector' => '#awesome-component-2', 'key12' => 'value12', 'key23' => 'value23', ] ] ]); }
Note how we define the *_selector key. That's because we're able to define our
selectors for each component (meaning we need to define a layer with the
appropriated selector in the view for each component).
That's in part because this plugin's helper loads components appending them to
the script view block. Depending on how do you work with your opencomponent
widgets this could bring some issues.
If so, you can just avoid using the helper and add the scripts wherever you want:
foreach ($oc_components as $component) { echo $component; }
License
This plugin code is licensed under a GNU GPL v.3 license.
alvarium/cake-oc 适用场景与选型建议
alvarium/cake-oc 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 186 次下载、GitHub Stars 达 4, 最近一次更新时间为 2017 年 12 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 alvarium/cake-oc 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alvarium/cake-oc 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 186
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2017-12-15