承接 wafl-lang/php-core 相关项目开发

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

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

wafl-lang/php-core

Composer 安装命令:

composer require wafl-lang/php-core

包简介

PHP implementation of the WAFL core

README 文档

README

PHP implementation of the WAFL (Wider Attribute Formatting Language) configuration pipeline. It loads .wafl files, resolves imports, evaluates expressions/tags, and validates the result against schemas declared in @schema blocks.

Package layout

File Role
src/ConfigLoader.php High-level orchestrator that chains all processing stages
src/Loader.php Reads files, resolves @import, extracts @schema / @eval blocks
src/Parser.php Indentation-aware parser that builds the intermediate AST
src/Resolver.php Resolves __expr nodes, conditional lists, and registered tags
src/DocumentEvaluator.php Runs the final evaluation pass (with $ symbols support)
src/SchemaValidator.php Validates the resolved config against schema definitions
src/TagRegistry.php Built-in tag registry (!rgb, !file) with extension points
src/TypeMetadataExtractor.php Captures key<Type> annotations before resolution
src/Utils.php Shared helpers (deepMerge, associative detection, etc.)

Installation

composer require wafl/php-core

Usage

use Wafl\Core\ConfigLoader;

$loader = new ConfigLoader();
$result = $loader->load(__DIR__ . '/app.wafl', [
    'env' => $_ENV,
]);

$config = $result['config'];
$meta = $result['meta'];

WAFL file example

@schema:
  App:
    name: string
    version: string
    port: int
    debug?: bool
    theme:
      primary: string
      secondary: string
    features: list<string>

app<App>:
  name: "WAFL Demo"
  version: "1.0.0"

  port = $ENV.PORT || 3000
  debug = $ENV.NODE_ENV === "dev"

  theme:
    primary = !rgb(255, 200, 80)
    secondary = "#111"

  features:
    - login
    - analytics
    - if $ENV.NODE_ENV === "dev": monitoring

Loading this file with ConfigLoader resolves tags/expressions and validates against schema.wafl:

[
    'app' => [
        'name' => 'WAFL Demo',
        'version' => '1.0.0',
        'port' => 3000,
        'debug' => false,
        'theme' => [
            'primary' => '#ffc850',
            'secondary' => '#111',
        ],
        'features' => ['login', 'analytics'],
    ],
]

Setting NODE_ENV=dev PORT=8080 would flip debug to true, set port to 8080, and include the monitoring feature. TagRegistry includes built-ins like !rgb and can be extended; @schema is optional but enforced when present.

Running tests

composer install
composer test

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-18