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

Php Config Printer Laravel Package

symplify/php-config-printer

Print Symfony service and parameter configs to clean PHP files using nikic/php-parser. Generate output for configured services only or full configs (e.g., from YAML arrays) via SmartPhpConfigPrinter and YamlToPhpConverter. Ideal for config transformations and automation.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Developer Experience (DX) for Laravel Teams:

    • Debugging Complex Configurations: Convert Laravel’s service container definitions (e.g., AppServiceProvider, bind() calls) into a human-readable PHP array format, reducing the "black box" nature of dynamic service bindings. This is particularly valuable for teams using runtime-generated services (e.g., via factories, dynamic providers, or third-party packages like spatie/laravel-medialibrary).
    • Onboarding Acceleration: Provide new developers with a single-source truth for service configurations, eliminating the need to trace bindings across multiple providers or package configs.
  • Tooling and Automation:

    • CI/CD Pipeline Integration: Automate config validation by generating PHP representations of service containers for static analysis (e.g., detecting unused services, circular dependencies, or security misconfigurations).
    • Dynamic Configuration Generation: Enable tools that generate Laravel service bindings on-the-fly (e.g., for microservices or serverless functions) by parsing configs into PHP arrays and then mapping them to Laravel’s container.
    • Legacy System Modernization: Migrate older Laravel apps (v5/v6) to newer versions by exporting service bindings to PHP for backward compatibility checks or gradual refactoring.
  • Security and Compliance:

    • Audit Trails: Extract service configurations for static analysis (e.g., identifying hardcoded secrets, overly permissive bindings, or sensitive data exposure in DI containers).
    • Compliance Reporting: Generate reports of service dependencies for SOC2/GDPR audits by converting opaque container definitions into inspectable PHP.
  • Roadmap for "Config-as-Code":

    • Config Diffing: Compare service containers across environments (e.g., local vs. staging) by converting bindings to PHP and using diff tools (e.g., php-diff).
    • IDE Support: Partner with IDE vendors (e.g., PHPStorm) to integrate parsed service configs for autocomplete, refactoring, or navigation (e.g., "Find all services tagged api").
    • Multi-Framework Collaboration: Share Laravel service definitions with non-Laravel teams (e.g., frontend devs) in a familiar PHP format, reducing context-switching overhead.
  • Build vs. Buy:

    • Avoid Reinventing the Wheel: Instead of building a custom PHP parser for Laravel’s service container, leverage this package’s Symfony-compatible parser and adapt it for Laravel-specific needs. This reduces technical debt and accelerates delivery.
    • Hybrid Approach: Use the package for parsing/analysis while building lightweight Laravel-specific adapters for integration (e.g., mapping Symfony tags to Laravel’s app()->tag()).

When to Consider This Package

  • Consider if:

    • Your Laravel team struggles with debugging opaque service bindings (e.g., dynamic providers, third-party packages, or runtime-generated services).
    • You need to automate config validation in CI/CD (e.g., detect unused services, circular dependencies, or misconfigurations).
    • You’re building internal tools that require inspecting or transforming Laravel’s service container (e.g., migration scripts, security scanners).
    • You want to modernize legacy Laravel apps by exporting service bindings to PHP for refactoring or compatibility checks.
    • Your team includes non-Laravel developers who need to understand service dependencies in a familiar format (PHP arrays).
    • You’re exploring "config-as-code" initiatives and need a foundation for diffing, generating, or visualizing configs.
  • Avoid if:

    • Your team doesn’t use complex service bindings (e.g., simple bind() calls with no dynamic logic).
    • You’re already satisfied with Laravel’s native debugging tools (e.g., php artisan container:dump, tinker, or IDE debugging).
    • Your PHP version < 8.2 (hard dependency for the package).
    • You need real-time parsing (this is a batch/CLI tool, not a runtime library).
    • Your configs are extremely complex (e.g., nested factories, closures, or custom container extensions) and may not parse cleanly into PHP.
    • You’re already using a mature alternative (e.g., spatie/laravel-config-array, custom scripts with nikic/php-parser, or Laravel’s built-in tools).
    • Your primary use case is Symfony migration, not Laravel-specific needs (consider native Laravel tools instead).

How to Pitch It (Stakeholders)

For Executives: *"This package helps us treat Laravel’s service container as first-class code—converting complex, scattered service bindings into inspectable PHP arrays. This unlocks critical capabilities for our team:

  • Faster Debugging: No more guessing what’s in AppServiceProvider or third-party packages. Generate a single PHP file with all service definitions.
  • Automated Compliance: Scan service configs for security risks (e.g., hardcoded secrets, overly permissive bindings) in CI/CD.
  • Tooling Foundation: Build internal tools (e.g., config diffing, migration scripts) without reinventing the wheel for PHP parsing. It’s a low-risk investment (MIT license, minimal dependencies) with high upside for developer productivity and code quality. Let’s prototype it for [specific pain point, e.g., onboarding or security audits]."*

For Engineering Leads: *"Symplify’s php-config-printer solves a hidden productivity drain in Laravel: debugging service bindings. Here’s how it helps us:

  • Debugging: Dump the entire service container to a PHP file in one command. No more tracing bindings across 20 providers.
  • CI/CD: Automate config validation (e.g., ‘Does this service have circular dependencies?’) by parsing bindings into PHP.
  • Tooling: Feed parsed configs into custom scripts (e.g., ‘Generate a report of all API-tagged services’).
  • Future-Proof: Prepare for ‘config-as-code’ without vendor lock-in. We can adapt the output for Laravel’s needs. Tradeoff: It’s Symfony-focused, so we’d need a lightweight adapter to map Symfony configs to Laravel’s container. But the core parsing is battle-tested. Let’s test it on [specific module, e.g., the API service layer]."*

For Developers: *"Imagine running a command and getting a single PHP file with every service binding in your Laravel app—no YAML, no magic, just plain PHP arrays. Here’s why this is useful:

  • Debugging: See exactly what’s bound where. No more php artisan tinker guessing games.
  • Collaboration: Share service configs with non-Laravel devs in a format they understand.
  • Tooling: Build scripts that analyze DI containers (e.g., ‘Find all services that depend on the DB’).
  • Legacy Code: Export old service bindings to PHP to refactor them safely. How it works:
  1. Define your services in a Symfony-compatible format (or use existing Laravel configs).
  2. Run the printer to generate a PHP file.
  3. Inspect or transform the output as needed. Want to try it on [specific service provider or package]?"*

For Architects/Tech Leads (Bonus): *"This package aligns with our modularity goals by:

  • Decoupling config parsing from Laravel’s container, making it reusable across tools.
  • Enabling hybrid Symfony/Laravel workflows if we ever adopt Symfony components.
  • Reducing technical debt by avoiding custom PHP parsers. Risk: The adapter layer will need to handle Laravel-specific quirks (e.g., tags, contextual binding), but the core parsing is solid. Let’s scope this as a 6-week spike to validate."*
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.
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
spatie/mailcoach-vapor