Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Dependencies Laravel Package

hermes/dependencies

Hermes is a CLI dev tool that exports your project’s Composer and/or NPM dependencies to a markdown report. Run vendor/bin/hermes and use flags for composer, package, all, custom path, and configurable output location.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require --dev hermes/dependencies
    

    Ensure the package is added to require-dev in your composer.json.

  2. First Run: Execute the CLI tool to generate a markdown file with dependencies:

    vendor/bin/hermes -c
    

    This generates a composer_dependencies.md file in the project root by default.

  3. Quick Use Case: Generate a combined report for both Composer and NPM dependencies:

    vendor/bin/hermes -a
    

    Outputs dependencies.md with structured tables for both dependency types.


Where to Look First

  • CLI Arguments: Check vendor/bin/hermes --help for available flags (-c, -p, -a, --path, --output).
  • Output Format: Inspect the generated markdown files to understand the structure (e.g., tables for dependencies, versions, and licenses).
  • Custom Paths: Use --path to target submodules or monorepo directories:
    vendor/bin/hermes -c --path ./modules/api
    

First Laravel Integration

  1. Automate in post-install-cmd: Add to your composer.json to generate dependency reports on install:
    "scripts": {
        "post-install-cmd": [
            "@php vendor/bin/hermes -a --output=docs/dependencies.md"
        ]
    }
    
  2. Publish to Docs: Commit the generated markdown to your docs/ folder and link it in your README.md:
    ## Dependencies
    See [full dependency report](./docs/dependencies.md).
    

Implementation Patterns

Workflows

  1. Dependency Audits:

    • Run vendor/bin/hermes -a before major releases to document dependencies.
    • Compare outputs across branches to track changes:
      vendor/bin/hermes -a --output=docs/dependencies-v1.md
      
  2. Monorepo Support:

    • Generate per-module reports:
      vendor/bin/hermes -c --path ./packages/auth --output=packages/auth/dependencies.md
      
  3. CI/CD Integration:

    • Add to Laravel’s phpunit.xml or GitHub Actions to validate dependencies:
      # .github/workflows/dependencies.yml
      - name: Generate Dependencies Report
        run: vendor/bin/hermes -a --output=docs/dependencies.md
      

Integration Tips

  1. Laravel Artisan Commands: Extend Hermes functionality by creating a custom Artisan command:

    // app/Console/Commands/GenerateDependencies.php
    namespace App\Console\Commands;
    
    use Illuminate\Console\Command;
    use Symfony\Component\Process\Process;
    use Symfony\Component\Process\Exception\ProcessFailedException;
    
    class GenerateDependencies extends Command
    {
        protected $signature = 'dependencies:generate
            {--type= : Type (composer|package|all)}
            {--output= : Output path}';
    
        public function handle()
        {
            $process = new Process(['vendor/bin/hermes', '-'.$this->option('type'), '--output='.$this->option('output')]);
            $process->run();
    
            if (!$process->isSuccessful()) {
                throw new ProcessFailedException($process);
            }
    
            $this->info('Dependencies report generated!');
        }
    }
    

    Register in app/Console/Kernel.php:

    protected $commands = [
        Commands\GenerateDependencies::class,
    ];
    

    Run with:

    php artisan dependencies:generate --type=all --output=docs/report.md
    
  2. Dynamic Documentation: Use Laravel’s Blade to embed dependency reports in admin panels:

    // routes/web.php
    Route::get('/admin/dependencies', function () {
        return view('admin.dependencies', [
            'composerDeps' => file_get_contents('docs/composer_dependencies.md'),
            'npmDeps' => file_get_contents('docs/package_dependencies.md'),
        ]);
    });
    
  3. Dependency Version Tracking: Parse the markdown output in Laravel to track versions over time:

    // app/Services/DependencyTracker.php
    public function parseComposerDependencies(string $markdown): array
    {
        $dependencies = [];
        preg_match_all('/\|([^\|]+)\|([^\|]+)\|([^\|]+)\|/', $markdown, $matches);
        foreach ($matches[0] as $i => $row) {
            $dependencies[$matches[1][$i]] = [
                'version' => $matches[2][$i],
                'license' => $matches[3][$i],
            ];
        }
        return $dependencies;
    }
    

Gotchas and Tips

Pitfalls

  1. Missing package.json or composer.json:

    • Hermes throws exceptions if files are missing. Handle gracefully in CI:
      - name: Generate Dependencies
        run: |
          if [ -f "composer.json" ]; then
            vendor/bin/hermes -c --output=docs/composer.md
          fi
          if [ -f "package.json" ]; then
            vendor/bin/hermes -p --output=docs/npm.md
          fi
      
  2. Output Overwrites:

    • Default outputs (composer_dependencies.md, package_dependencies.md) overwrite on each run. Use --output to avoid conflicts:
      vendor/bin/hermes -a --output=docs/dependencies-$(date +%Y-%m-%d).md
      
  3. NPM DevDependencies:

    • By default, Hermes includes both dependencies and devDependencies from package.json. Exclude dev dependencies by modifying the package’s logic or pre-processing package.json:
      jq 'del(.devDependencies)' package.json > temp.json && vendor/bin/hermes -p --path=temp.json
      

Debugging

  1. Verbose Output:

    • Hermes lacks verbose logging. Debug by inspecting the generated markdown or adding error_log calls to the package’s src/Hermes.php.
  2. Path Issues:

    • If --path fails, ensure the path is absolute or relative to the project root. Use pwd to verify:
      cd /path/to/project && vendor/bin/hermes -c --path ./subdir
      
  3. Permission Errors:

    • Ensure the output directory is writable:
      mkdir -p docs && chmod -R 777 docs
      

Tips

  1. Custom Templates:

    • Extend Hermes by modifying its markdown template (located in src/Templates/DependenciesTemplate.php). Fork the package or create a wrapper:
      // app/Services/CustomHermes.php
      use Hermes\Dependencies\Templates\DependenciesTemplate;
      
      class CustomDependenciesTemplate extends DependenciesTemplate
      {
          public function renderComposer(array $dependencies): string
          {
              // Custom logic (e.g., add columns for security advisories)
              return "```\n".implode("\n", $dependencies)."\n```";
          }
      }
      
  2. Git Hooks:

    • Auto-generate reports on pre-commit to track dependency changes:
      # .git/hooks/pre-commit
      #!/bin/sh
      vendor/bin/hermes -a --output=docs/dependencies.md && git add docs/dependencies.md
      
  3. Security Audits:

    • Combine Hermes with composer why-not or npm audit to flag vulnerable dependencies:
      vendor/bin/hermes -c --output=docs/safe-deps.md && composer why-not --platform
      
  4. Performance:

    • Hermes is lightweight, but parsing large monorepos may slow down. Cache outputs:
      vendor/bin/hermes -a --output=docs/dependencies.md || true  # Skip if fails
      
  5. Local Development:

    • Symlink Hermes globally for easier access:
      ln -s vendor/bin/hermes /usr/local/bin/hermes
      
    • Now run from anywhere:
      hermes -c --path=/path/to/project
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky