slothsoft/farah 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

slothsoft/farah

Composer 安装命令:

composer require slothsoft/farah

包简介

Files and Resources and Hypertext: A content management system.

README 文档

README

Packagist Version PHP Version Support Documentation Test Status license badge

Files and Resources and Hypertext: a manifest-driven content management and asset delivery package for slothsoft modules.

Farah resolves farah://vendor@module/path?arguments#stream URLs through XML manifests, turns assets into executable results, and exposes those results as PSR-7 responses, DOM writers, file writers, stream writers, or chunk writers. It also ships the XML schemas, XSLT assets, JavaScript helpers, and small command-line tools used by existing Farah modules.

This is an older slothsoft package with active infrastructure and historical compatibility code. The package is kept installable for existing consumers, but not every namespace is recommended for new code.

Compatibility Policy

Semantic versioning is in effect. Public classes are public API, including public constructors, methods, constants, and properties. Public signatures must remain backward-compatible unless an API-breaking change is specifically requested for a major release.

All code in this package must remain syntactically valid on the PHP version declared by PHP_VERSION in .env and behaviorally compatible with every PHP version covered by CI.

Bug fixes are allowed in every area of the package, including deprecated and historical APIs. Deprecated APIs should not be used for new code, but they are still expected to keep working for existing consumers, including compatibility fixes for newer PHP versions.

Adding dependencies is acceptable when the dependency is justified by the change and remains compatible with this package's supported PHP versions.

Current / Supported Areas

These parts are suitable for use in new or maintained Farah code:

  • Slothsoft\Farah\Kernel
    • Request/response orchestration for Farah page and asset lookups.
    • Process-wide current request, page, sitemap, and tracking configuration.
  • Slothsoft\Farah\FarahUrl
    • Immutable Farah URL value objects for authorities, paths, query arguments, and stream identifiers.
    • PSR-7 UriInterface integration for the farah://vendor@module/path?arguments#stream URL format.
  • Slothsoft\Farah\Module
    • Module registration and resolution from manifest to asset, executable, result, and writer interfaces.
    • File-system cache/data path helpers scoped by Farah URL.
  • Slothsoft\Farah\Module\Manifest
    • XML manifest loading and asset construction.
    • Strategy interfaces for tree loading and asset building.
  • Slothsoft\Farah\Module\Asset
    • Asset lookup, path resolution, manifest instructions, parameter filtering, parameter suppliers, and executable builders.
    • Built-in instruction strategies for imports, links, templates, documents, manifests, scripts, stylesheets, and dictionaries.
  • Slothsoft\Farah\Module\Executable
    • Executable lookup and result building.
    • Result builders for DOM writers, file writers, streams, chunk writers, transformations, maps, proxies, and CLI delegation.
  • Slothsoft\Farah\Module\Result
    • Result lookup and conversion into DOM, file, stream, string, and chunk writer forms.
  • Slothsoft\Farah\RequestStrategy and Slothsoft\Farah\ResponseStrategy
    • Page, asset, and route lookup strategies.
    • Header/body response sending strategies.
  • Slothsoft\Farah\Http
    • Namespaced HTTP helpers for PSR-7 messages, status codes, content coding, transfer coding, and identity encoding.
  • Slothsoft\Farah\LinkDecorator
    • HTML, SVG, and Farah link decoration for generated DOM output.
  • Slothsoft\Farah\StreamWrapper
    • Stream wrapper factory and wrappers for Farah document and string resources.
  • Slothsoft\Farah\Schema
    • Schema lookup for bundled Farah XML schemas.
  • Slothsoft\Farah\Exception
    • Package-specific exception types and DOM-serializable exception context.
  • Slothsoft\Farah\Internal
    • Built-in executable builders for Farah's bundled module assets, such as sitemap, request, phpinfo, and font-face generation.
  • Slothsoft\Farah\Dictionary
    • Dictionary loading and transformation helpers used by older XML/XSLT workflows.
  • Slothsoft\Farah\Sites
    • Domain and sitemap lookup model for page routing.
  • Slothsoft\Farah\Configuration
    • Mutable configuration field wrappers for Farah URLs and assets.
  • assets/
    • Farah's own module manifest, XML schemas, XSLT templates, sitemap generator assets, and JavaScript helper assets.
  • scripts/farah-asset and scripts/farah-page
    • Composer binaries for resolving a Farah asset URL or page URL from the command line.

Historical / Deprecated

These components are included for historical reasons only. Do not use them for new code.

  • Slothsoft\Farah\Cache
    • Small cache helpers retained for existing module behavior.
  • Slothsoft\Farah\Container
    • Minimal container interface used by existing code.
  • Slothsoft\Farah\Daemon
    • Socket-based daemon server/client helpers for long-running executable builders.
  • Slothsoft\Farah\Security
    • Banned-user/session helper retained for existing deployments.
  • Slothsoft\Farah\Session
    • Legacy session persistence helper.
  • Slothsoft\Farah\Tracking
    • Request tracking, log table, archive, tick, and view helpers.
  • Slothsoft\Farah\HTTPClosure, HTTPCommand, HTTPEvent, HTTPRequest, and HTTPResponse
    • Legacy root-level HTTP classes predating the current PSR-7 request/response flow.
    • Prefer Slothsoft\Farah\Http, Slothsoft\Farah\RequestStrategy, Slothsoft\Farah\ResponseStrategy, and PSR-7 message interfaces for new code.
  • Slothsoft\Farah\PThreads in src-pthreads/
    • Deprecated pthreads integration retained for old consumers.
    • New code should avoid ext-pthreads and use maintained process, queue, or async infrastructure instead.
  • The /sites asset in assets/manifest.xml
    • Deprecated alias for /current-sitemap.

Farah Modules

A Farah module is registered with a vendor/module authority and an asset directory:

use Slothsoft\Farah\Module\Module;

Module::registerWithXmlManifestAndDefaultAssets(
    'slothsoft@farah',
    __DIR__ . '/assets'
);

The module manifest describes resources, directories, fragments, custom assets, imports, links, templates, parameter filters, and executable builders. Farah then resolves URLs through the pipeline:

FarahUrl -> Manifest -> Asset -> Executable -> Result -> Writer/Response

Example URLs:

farah://slothsoft@farah/schema/module/1.1#file
farah://slothsoft@farah/current-sitemap#xml
farah://slothsoft@farah/sitemap-generator#html

See assets/manifest.xml, assets/example-domain.xml, and test-files/ for canonical examples of manifests, domains, dictionaries, transformations, and path resolution behavior.

Command-Line Usage

Install dependencies first:

composer install

Retrieve an asset by Farah URL:

composer exec farah-asset "farah://vendor@module/path/to/asset?arguments#stream-type"

Retrieve a page by URL path:

composer exec farah-page "/path/to/page?arguments#stream-type"

Development Notes

Some APIs use global or static process state, especially Kernel, Module, configuration fields, stream wrappers, session/tracking helpers, and request/page/sitemap state. Tests that exercise stateful behavior should isolate side effects with @runInSeparateProcess.

Tests may create temporary files through temp_file, temp_dir, or Slothsoft\Core\IO\FileInfoFactory::createTempFile; those helpers do not require manual cleanup. Files in test-files/ are canonical fixtures.

The local development environment should provide the Composer development extensions. If an optional extension or platform feature is unavailable, affected tests may be skipped or impossible to run locally. Skipped tests should be treated as intentionally skipped unless the task is specifically about test skipping.

Use .editorconfig for coding style. Additional formatter or static-analysis tooling may be added later, but none is required right now.

Run tests with:

vendor/bin/phpunit

The full suite can take up to 600 seconds. Some API tests use browser mocking to validate the bundled JavaScript assets, including the first-run browser driver detection/download step.

Generate API documentation with:

vendor/bin/phpdoc

Installation

composer require slothsoft/farah

Requirements

See composer.json for required PHP extensions and optional development extensions.

slothsoft/farah 适用场景与选型建议

slothsoft/farah 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20.04k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 12 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「docs」 「farah-module」 「slothsoft」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 slothsoft/farah 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-28