定制 mattjmattj/plux 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mattjmattj/plux

Composer 安装命令:

composer require mattjmattj/plux

包简介

Librairy for implementing a Flux-like one-direction flow architecture server-side

README 文档

README

Build Status Scrutinizer Code Quality Code Coverage

introduction

plux is a PHP library created to answer a simple question:

Does implementing a Flux-like, one-direction flow architecture server-side make any sense?

quick how-to

installation

composer require mattjmattj/plux

initialization

Somewhere in the bootstrap of your application/framework you need to call

\Plux\Plux::initialize();

Plux will then create a Dispatcher that will have to handle the Actions and pass them to your registerd Stores.

stores

Stores are like the ones in Flux. They should do the business part according to an action that is given to them through their handle method. Note that using the handle method is just a shortcut provided by the StoreTrait, but any callable can be used with the Dispatcher.

You must register your Stores to Plux and give them a name :

\Plux\Plux::addStore('Foo', new \My\Super\Store\Bar());

The name will allow other parts of your application to call

\Plux\Plux::getStore('Foo');

Stores are supposed to emit events whenever they perform an action. Plux depends on evenement/evenement to implement Store events.

actions

Actions must be created and dispatched to allow registered Stores to do their job. Actions are composed of two elements:

  • a type
  • a data array

After creating an action, you must dispatch it :

$action = new \Plux\Action ('type', ['foo' => 'bar']);
\Plux\Plux::getDispatcher()->dispatch($action);

components

Theoretically everybody can listen to Store events, but to make things easier Plux provides a Component trait with a single render function. When render is called the Component should output whatever it needs to. This part is left very opened and you are not forced to use the Component trait at all.

example

A small but complete example of implementation is available here

debate

You think that even in a per-request context like in PHP, implementing a one-direction flow architecture is a great idea? You think that it is absurd? Do not hesitate and leave a comment in the dedicated issue

license

plux is released under the FreeBSD License

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 115
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: FreeBSD
  • 更新时间: 2014-10-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固