anja/ghost-hunter-bundle 问题修复 & 功能扩展

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

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

anja/ghost-hunter-bundle

Composer 安装命令:

composer require anja/ghost-hunter-bundle

包简介

A quality assistant to hunt down unused files (templates & assets) in Symfony.

README 文档

README

Pipeline Status Coverage Report Latest Stable Version

"Who you gonna call?"

GhostHunterBundle is a code quality tool for Symfony 6.4+ and 7.0+. It performs a deep analysis of your project to detect orphaned files (Twig templates and Assets) and helps you safely remove them.

✨ Features

  • 🕸️ Deep Dependency Analysis: Builds a complete dependency graph to find not just directly unused files, but also "transitive ghosts" – files that are only used by other unused files.
  • ⚡️ Blazing Fast with Cache: Subsequent analyses are instantaneous thanks to a smart caching system.
  • 🧠 Smart Parsing: Intelligently ignores files mentioned in comments (Twig {# ... #}, PHP //, CSS /* ... */).
  • 🗑️ Soft Delete: No files are permanently deleted. They are moved to a var/ghost_trash/ directory, organized by date.
  • ⚙️ Configurable: Exclude specific directories or files from the analysis.

📦 Installation

Install the bundle via Composer:

composer require anja/ghost-hunter-bundle --dev

If you are not using Symfony Flex, enable the bundle in config/bundles.php:

return [
    // ...
    Anja\GhostHunterBundle\GhostHunterBundle::class => ['dev' => true],
];

⚙️ Configuration

Create a configuration file config/packages/ghost_hunter.yaml to define paths to ignore:

ghost_hunter:
  # List of directories or files to exclude from analysis
  ignored_paths:
    - "node_modules"
    - "var"
    - "vendor"
    - "tests"
    - "admin" # Example: ignore the admin section

🎮 Usage

Run the interactive command from your terminal:

php bin/console guardian:ghosts

Note: By default, this command is interactive. It asks for confirmation before deleting anything.

Available Options

You can target a specific file type (though deep analysis is recommended):

# Analyze only Twig templates (less effective with deep analysis)
php bin/console guardian:ghosts --type=templates

# Analyze only assets
php bin/console guardian:ghosts --type=assets

CI / Audit Mode

Returns an exit code 1 if unused files are found. Ideal for CI pipelines.

php bin/console guardian:ghosts --dry-run

Cache Management

The cache is enabled by default. To force a fresh analysis, use the --no-cache flag.

php bin/console guardian:ghosts --no-cache

🛡️ Security (Soft Delete)

This bundle applies a "Soft Delete" policy.

When you confirm file deletion:

  1. A var/ghost_trash directory is created at your project root.
  2. A dated sub-directory is created (e.g., 2026-01-06_20-30-00).
  3. The original file structure is recreated there.

Example: If you delete assets/images/old-logo.png, it will be moved to: var/ghost_trash/2026-01-06_20-30-00/assets/images/old-logo.png.

This allows you to manually restore any file in case of error.

🤝 Contribution

Contributions are welcome!

  1. Fork the project.
  2. Create your branch (git checkout -b feature/AmazingFeature).
  3. Commit your changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin feature/AmazingFeature).
  5. Open a Pull Request.

📝 Author

Developed with ❤️ by mlejeune.

📄 License

This project is licensed under the MIT License.

anja/ghost-hunter-bundle 适用场景与选型建议

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

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

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

围绕 anja/ghost-hunter-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-07