niklan/composer-directories
Composer 安装命令:
composer require niklan/composer-directories
包简介
Composer plugin that automatically creates directories defined in your composer.json.
README 文档
README
A Composer plugin that automatically creates directories and symlinks defined in your composer.json during install and update commands. Directories are always created before symlinks.
Installation
composer require niklan/composer-directories
Usage
Add configuration to the extra section of your composer.json:
{
"extra": {
"ensure-directories": [
"web/sites/simpletest/browser_output",
"var/log",
"var/files/public",
{"path": "var/files/private", "permissions": "0700"}
],
"symlinks": {
"var/files/public": "web/sites/default/files"
}
}
}
Both features work independently -- you can use directories, symlinks, or both.
Directories
- String entries use the default permission
0775(drwxrwxr-x), matching the Drupal default. - Object entries accept a
pathand an optionalpermissionsstring in octal format. - All paths are relative to the project root (where
composer.jsonis located).
Symlinks
- Keys are targets, values are link paths. Both are relative to the project root.
- If a symlink already exists and points to the correct target, it is left as-is. If it points elsewhere, it is replaced.
- If a non-symlink file/directory exists at the link path, it is skipped with a warning.
- On Windows, directory junctions are used instead of symlinks (no admin rights needed).
Verbose output
Run composer install -v to see skipped directories and symlinks that already exist:
> post-install-cmd: Niklan\ComposerDirectories\DirectoriesPlugin->onPostCommand
Directory exists: var/files/private
Directory exists: var/files/private/translations
Directory exists: var/files/public
Directory exists: var/files/temporary
Directory exists: var/log
Symlink exists: web/sites/default/files
Security
Paths that resolve outside the project root (e.g., ../../../etc) are rejected with a warning. This applies to both directories and symlinks (target and link).
Development
Requirements
- PHP 8.2+
- Composer 2.x
Setup
composer install
Linting
# Run all linters composer lint # Run individually composer phpcs # PHP CodeSniffer (PSR-12 + Slevomat) composer phpstan # PHPStan (level 10)
Auto-fix code style
composer phpcbf
Testing
composer phpunit
Run everything
composer test
License
MIT
niklan/composer-directories 适用场景与选型建议
niklan/composer-directories 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.81k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「directories」 「composer-plugin」 「mkdir」 「ensure-directories」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 niklan/composer-directories 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 niklan/composer-directories 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 niklan/composer-directories 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Composer plugin for preserving custom paths and supporting nested packages
Composer plugin
PhpPlaisio: Directories
Easy system for work with files and directories
PhpPlaisio: Core Directories
Composer plugin that verifies GitHub build-provenance attestations for the packages you install
统计信息
- 总下载量: 1.81k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-05