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/, andsrc/ - 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, andRootConfig
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
DiscoveryConfigFactoryDiscoveryConfigValidatorDiscoveryConfig
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 (
skiporfail) - 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
- Discovery flow documentation
- Architecture overview documentation
- Configuration system documentation
- File locator API documentation
- Config loading integration documentation
- Development setup documentation
- Implementation guidelines documentation
- Testing strategy documentation
- Supported extension points 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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 liquidrazor/file-locator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
A PHP class providing static methods for reading, writing, copying, moving, and deleting files and directories, MIME type detection, image size detection, and file permission management
Supporing Symfony's DependencyInjection component for your symfony1 project
The flysystem adapter for yandex disk rest api.
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
phpABLE file-system library
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-26