承接 liquidrazor/file-locator 相关项目开发

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

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

liquidrazor/file-locator

Composer 安装命令:

composer require liquidrazor/file-locator

包简介

Minimal filesystem discovery component for LiquidRazor.

README 文档

README

A lightweight, high-performance filesystem discovery component for the LiquidRazor ecosystem.

This library provides a deterministic, memory-efficient, and extensible way to locate PHP files across a project using convention-first defaults with optional project-level overrides.

It is the first step in the LiquidRazor pipeline:

filesystem → files → classes → descriptors → DI registry

Features: Core Capabilities

  • Fast, iterator-based filesystem traversal with low memory use
  • Convention-first defaults for include/, lib/, and src/
  • YAML-based configuration loaded through liquidrazor/config-loader
  • Clean separation of concerns with no DI, reflection, or PHP parsing
  • Safe traversal with configurable symlink, hidden file, and unreadable path handling
  • Config loading delegated to a dedicated LiquidRazor library

Default Behavior: Built-In Roots And Exclusions

Out of the box, the discovery system scans:

  • include/
  • lib/
  • src/

With automatic exclusions:

  • vendor/
  • node_modules/
  • .git/
  • .idea/
  • .vscode/
  • var/cache/

Only .php files are considered.

Configuration: Config Sources

1. Default Configuration (Library)

The library ships with an internal configuration:

resources/config/roots.yaml

This defines the baseline discovery rules.

2. Project Override

You can override or extend discovery behavior by adding:

config/roots.yaml

or

config/roots.yml

Config loading is delegated to liquidrazor/config-loader with YAML selected explicitly. If both config/roots.yaml and config/roots.yml exist, loading fails instead of silently picking one.

Configuration Structure: Supported YAML Shape

discovery:
  defaults:
    follow_symlinks: false
    include_hidden: false
    on_unreadable: skip
    extensions: [php]

  exclude:
    - vendor
    - node_modules
    - .git

  roots:
    include:
      enabled: true
      path: include
      recursive: true
      extensions: [php]
      exclude: []

    lib:
      enabled: true
      path: lib
      recursive: true
      extensions: [php]
      exclude: []

    src:
      enabled: true
      path: src
      recursive: true
      extensions: [php]
      exclude: []

Adding Custom Roots: Extending Discovery

discovery:
  roots:
    modules:
      path: modules
      recursive: true

Excluding Paths: Global And Root-Specific Rules

Global exclusions:

discovery:
  exclude:
    - storage/tmp

Root-specific exclusions:

discovery:
  roots:
    src:
      exclude:
        - src/Legacy
        - src/Experimental

Disabling Default Roots: Removing Built-In Paths

discovery:
  roots:
    lib:
      enabled: false

Config Loading Boundary

FileLocator no longer locates config files by full path, reads raw config contents, parses YAML, merges raw config layers, or interpolates environment variables itself.

Those responsibilities now belong to liquidrazor/config-loader.

DiscoveryConfigFactory only:

  • asks ConfigLoader for normalized config arrays using the logical name roots
  • validates the discovery schema
  • normalizes project-relative paths
  • builds DiscoveryConfig, DiscoveryDefaults, and RootConfig

Merge Strategy: How Config Is Built

Configuration is built as:

library defaults + project overrides → final discovery config

The default resource is loaded from resources/config/roots.yaml. The optional project override is loaded from the project config root using the logical name roots.

Raw config merge behavior now follows liquidrazor/config-loader:

  • Associative arrays → merged recursively
  • Scalars → overridden by later config
  • Indexed arrays → replaced by later config

After loading, FileLocator still validates the discovery schema and removes disabled roots from the runtime config.

Architecture: Main Layers

The system is intentionally split into layers:

1. Config Layer

  • DiscoveryConfigFactory
  • DiscoveryConfigValidator
  • DiscoveryConfig

2. Discovery Layer

  • FileLocator
  • streaming traversal using generators
  • zero accumulation by default

3. Future Layers

  • Class discovery (static parsing)
  • DI registry loading

Usage: Basic Flow

use LiquidRazor\FileLocator\Config\DiscoveryConfigFactory;
use LiquidRazor\FileLocator\FileLocator;

$factory = new DiscoveryConfigFactory();
$config = $factory->create(__DIR__);
$locator = new FileLocator($config);

foreach ($locator->locate() as $file) {
    // process file
}

The locator yields files lazily, ensuring minimal memory usage.

Performance Principles: Traversal Behavior

  • Depth-first traversal
  • Early directory pruning
  • Generator-based streaming
  • No reflection or file inclusion
  • No unnecessary allocations

Safety: Failure And Traversal Controls

  • Unreadable paths: configurable (skip or fail)
  • Symlinks: disabled by default
  • Hidden files: excluded by default
  • Deterministic behavior (no implicit magic)

Design Philosophy: Implementation Priorities

  • Convention over configuration (but never forced)
  • Explicit over implicit
  • Small, composable components
  • No framework lock-in
  • Predictable behavior under load

Role in LiquidRazor: Pipeline Position

This component is the foundation of the DI pipeline:

FileLocator
   ↓
ClassLocator (future)
   ↓
RegistryLoader (future)
   ↓
DIRegistry

Notes: Additional Documentation

License: Package Terms

MIT

liquidrazor/file-locator 适用场景与选型建议

liquidrazor/file-locator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 liquidrazor/file-locator 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-26