marklj/funnel
Composer 安装命令:
composer require marklj/funnel
包简介
A catch-all controller (for Laravel).
README 文档
README
A catch-all controller (for Laravel)
Installation
- Install from Composer:
composer require marklj/funnel
- Add
Marklj\Funnel\FunnelServiceProviderto yourapp.phpservice provider configuration values. - Publish the packages configuration:
php artisan vendor:publish
Quick Start
1. Send a request
Send a POST request to /mailbox. You can do this with AJAX from your front-end library of choice (Angular / Vue / etc), but for simplicity, we'll use a simple HTML form example.
The default Funnel endpoint is /mailbox, but this can be configured in the funnel.php configuration file that was published in the installation section.
The command request parameter is required and is automatically converted to StudlyCase when processed by Funnel.
<form action="/mailbox" method="POST"> <input type="hidden" name="command" value="post_blog" /> <input type="text" name="payload[blog_title]" /> <button>Submit</button> </form>
Note that data does not need to be contained in a payload[] array unless you want to filter exactly what perameters are passed to your action. If you do not namespace your inputs, like name="blog_title", all of your input data will be passed to your action.
2. Map to an Action
Funnel will try to associate the StudlyCase command, in this case PostBlog, to an action. This association is made in the funnel.php configuration file.
// config/funnel.php [ // ... 'action_mappings' => [ 'PostBlog' => \App\Blog\Actions\PostAction::class, // other mappings here ] ]
3. Create Action
The action class must implement the Marklj\Funnel\Actionalble interface. You are free to place whatever code you need here.
All of your payload data data will be available in the ActionPayload object.
<?php namespace App\Blog\Actions; use Marklj\Funnel\Actionable; use Marklj\Funnel\ActionPayload; class PostAction implements Actionable { public function __invoke(ActionPayload $payload) { print 'Hello Funnel!'; print 'Blog Post Title: ' . $payload->get('blog_title'); } }
Since the action is instantiated using Laravel's IoC container, you are free to inject any dependancies into your action via the constructor.
marklj/funnel 适用场景与选型建议
marklj/funnel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 09 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 marklj/funnel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 marklj/funnel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2016-09-27