teknoo/recipe
Composer 安装命令:
composer require teknoo/recipe
包简介
Inspired by cooking, allows the creation of dynamics workflows, called here recipe, following the #east programming and using middleware, configurable via DI or any configuration, if a set of conditions (ingredients) are available.
README 文档
README
Inspired by cooking, allows the creation of dynamic algorithm, called here recipe, following the #east programming and using middleware, configurable via DI or any configuration, if a set of conditions (ingredients) are available.
A complete documentation is available in documentation/README.md
Quick Example
<?php
declare(strict_types=1);
use Teknoo\Recipe\Dish\DishClass;
use Teknoo\Recipe\Ingredient\Ingredient;
use Teknoo\Recipe\Recipe;
use Teknoo\Recipe\Chef;
use Teknoo\Recipe\ChefInterface;
use Teknoo\Recipe\Promise\Promise;
require 'vendor/autoload.php';
$recipe = new Recipe();
$recipe = $recipe->require(
new Ingredient(\DateTime::class, 'date')
);
$recipe = $recipe->cook(
function (\DateTime $date, ChefInterface $chef): void {
$date = $date->setTimezone(new \DateTimeZone('UTC'));
$chef->continue(['date' => $date]);
},
'convertToUTC'
);
$recipe = $recipe->cook(
function (\DateTime $date, ChefInterface $chef): void {
$immutable = \DateTimeImmutable::createFromMutable($date);
$chef->finish($immutable);
},
'immutableDate'
);
$output = '';
$recipe = $recipe->given(
new DishClass(
\DateTimeImmutable::class,
new Promise(
function (\DateTimeImmutable $immutable) use (&$output): void {
$output = $immutable->format('Y-m-d H:i:s T');
},
function (\Throwable $error) use (&$output): void {
$output = $error->getMessage();
}
)
)
);
$chef = new Chef;
$chef->read($recipe);
$chef->process(['date' => new \DateTime('2020-06-27 00:00:00', new \DateTimeZone('Europe/Paris'))]);
//Show : 2020-06-26 22:00:00 UTC
echo $output.PHP_EOL;
Others examples are available into demo
A complete documentation is available in documentation/README.md
Support this project
This project is free and will remain free. It is fully supported by the activities of the EIRL. If you like it and help me maintain it and evolve it, don't hesitate to support me on Patreon or Github.
Thanks :) Richard.
Credits
EIRL Richard Déloge - https://deloge.io - Lead developer. SASU Teknoo Software - https://teknoo.software
About Teknoo Software
Teknoo Software is a PHP software editor, founded by Richard Déloge, as part of EIRL Richard Déloge. Teknoo Software's goals : Provide to our partners and to the community a set of high quality services or software, sharing knowledge and skills.
License
Recipe is licensed under the 3-Clause BSD License - see the licenses folder for details.
Installation & Requirements
To install this library with composer, run this command :
composer require teknoo/recipe
This library requires :
* PHP 8.1+
* A PHP autoloader (Composer is recommended)
* Teknoo/Immutable.
* Teknoo/States.
News from Teknoo Recipe 4.0
This library requires PHP 8.1 or newer. Some change causes bc breaks.
- Use readonly properties for immutables objects.
- Constant
BowlInterface::METHOD_NAMEis final. - Support
FiberintoPromise. - Support
FiberintoBowlandDynamicBowlthanks to dynamics classes :- callable will be automatically wrapped by a fiber,
- the fiber object will be available as parameter for bowls.
- Add
Fibersupport to RecipeBowl, also in a dedicated classFiberRecipeBowl. The Fiber instance is also passed into workplan. - Add a
CookingSupervisorInterfaceand its default implementationCookingSupervisorto manage Bowls Fibers executions and loop on each active fiber.CookingSupervisorare also available as parameter for bowls.
News from Teknoo Recipe 3.1
This library requires PHP 8.0 or newer.
- Add
MergeableInterfaceandChefInterface::merge()to allow merge ingredient instead of replace it withupdateWorkplanwithout fetch it into step. - Add
TransformableInterfaceand attributeTransformto allow transform an ingredient before to put it into the bowl
News from Teknoo Recipe 3.0
This library requires PHP 8.0 or newer. Some change causes bc breaks.
- Promise immutable check is performed before var assignment
- Some optimisations on array functions to limit O(n)
- Subs chefs executing an embedded recipe inherit also of error handler with the workplan but can be changed without impact the original handler in the main chef.
- Subs chefs call also theirs top chef's callErrors method on error
- Add
interruptCookingmethod to stop execution of chef without execute finals steps (dish validation or error handlers) - Add
stopErrorReportingmethod to stop error reporting to top chef
News from Teknoo Recipe 2.0
This library requires PHP 7.4 or newer. Some change causes bc breaks :
- PHP 7.4 is the minimum required
- Most methods have been updated to include type hints where applicable. Please check your extension points to make sure the function signatures are correct.
- Switch to typed properties _ All files use strict typing. Please make sure to not rely on type coercion.
- Replace array_merge by "..." operators for integer indexed arrays
- Remove some PHP useless DockBlocks
- Enable PHPStan in QA Tools and disable PHPMd
- Enable PHPStan extension dedicated to support Stated classes
Contribute :)
You are welcome to contribute to this project. Fork it on Github
teknoo/recipe 适用场景与选型建议
teknoo/recipe 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 30.54k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2017 年 11 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「workflow」 「middleware」 「dynamic」 「Algorithm」 「recipe」 「East」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 teknoo/recipe 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 teknoo/recipe 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 teknoo/recipe 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Workflow for NetCommons Plugin
Flexslider slideshow content block for Silverstripe Elemental
EAV modeling package for Eloquent and Laravel.
Write down your routing mapping at one place
Workflow logger
统计信息
- 总下载量: 30.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 28
- 依赖项目数: 10
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-11-11