承接 isaeken/brick-engine 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

isaeken/brick-engine

Composer 安装命令:

composer require isaeken/brick-engine

包简介

A simple language engine for your templates.

README 文档

README

BrickEngine is a simple, flexible, and extensible script engine written in PHP.
It allows you to manage custom business rules, e-commerce discounts, automation scenarios, or any workflow you define without "changing code."

Status: The project is still in development and may not yet be fully ready for production use.
Support Us: If you like the project, please star it or contribute to support its development.

Why Choose BrickEngine?

Features

  • Dynamic Scripting Language: BrickEngine supports a wide range of operations through its flexible scripting language.
  • Easy Extensibility: You can add your own functions (e.g., apply_discount, dump, json_decode) and variables to the context. All functions and variables must be explicitly defined and bound to BrickEngine.
  • API & External Integrations: Whether for e-commerce, payment systems, or microservices, you can utilize scripts to make external API calls.
  • Clean and Readable Syntax: Easily perform conditional operations using simple if structures, loops, and assignments.
  • Performance and Flexibility: Centralize and manage your business rules to avoid complex branching and if-else chains.
  • Support for Various Data Types: Operate on different data types, such as strings, numbers, booleans, and arrays.
  • Loop and Conditional Structures: Includes support for control structures like while, if-else, and for loops.

Installation

Via Composer

composer require isaeken/brick-engine

Quick Start

The example below demonstrates a simple script that applies a discount if the cart total exceeds 100 units and then processes an e-commerce scenario by fetching a response from an external API.

<?php

require __DIR__ . '/vendor/autoload.php';

use IsaEken\BrickEngine\BrickEngine;

$script = <<<BRICK
if (cart['total'] > 100) {
    apply_discount();
    return "You have a discount!";
}

cart = {
    total: cart['total'],
    isPaid: false,
    sendApiRequest: function (url) {
        response = fetch(url);
        response = json_decode(response);
        return response['message'];
    },
};

return {
    success: true,
    message: cart.sendApiRequest('https://api.example.com'),
};
BRICK;

$engine = new BrickEngine();

// Define functions to be used within the script
$engine->context->setFunction('apply_discount', function () use ($engine) {
    // resolve variable value
    $value = fromValue($engine->context->variables['total']);
    
    return $value - 10;
});

// Define variables to be used in the script
$engine->context->setVariable('total', 120);

$result = $engine->run($script)->value->data;
echo $result; // "You have a discount!" or API message

How It Works

  1. The BrickEngine class interprets and executes the script.
  2. Functions in the context->functions array can be directly accessed within the script.
  3. The context->variables array defines variables that can be accessed in the script, such as cart['total'].

Running in Docker

You can run the example script in a Docker container using the following commands:

docker build -t brick-engine .
docker run --rm -v "$(pwd)":/app brick-engine ./examples/example.bee

Use Cases

  • E-Commerce Rules: Create dynamic business rules for cart totals, shipping cost calculations, or payment steps.
  • Form Validation / Workflow: Process user inputs and direct them to different scenarios.
  • Content Management: Apply dynamic rule sets for news, blogs, or similar content platforms.
  • API & Microservice Integration: Manage external API calls based on specific conditions (e.g., order confirmation, payment processing).
  • Game / Application Logic: Manage simple rule sets for game servers or create rapid prototypes using mini-scripts within applications.

Roadmap

Read the full ROADMAP.md file for more details on the project's future development plans.

License

This project is licensed under the MIT License. For more information, see the LICENSE.md file.

Contact & More Information

isaeken/brick-engine 适用场景与选型建议

isaeken/brick-engine 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 8, 最近一次更新时间为 2025 年 01 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 isaeken/brick-engine 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 isaeken/brick-engine 我们能提供哪些服务?
定制开发 / 二次开发

基于 isaeken/brick-engine 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-24