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

Laravel Config Validator Laravel Package

ashallendesign/laravel-config-validator

Validate your Laravel config at runtime or via Artisan. Define rulesets for config files with custom messages and environment targeting, generate rulesets quickly, and optionally publish defaults. Catch missing/invalid config early in local, CI, or production.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Validation Layer Alignment: The package introduces a declarative validation layer for Laravel’s configuration system, which aligns well with modern Laravel architectures (e.g., DDD, layered apps) where config validation is critical for runtime safety and consistency. It complements Laravel’s built-in config() helper by adding structured validation rules (e.g., required fields, type constraints, nested validation).
  • Separation of Concerns: Validates config without modifying core Laravel logic, adhering to the principle of least surprise. Rules are defined in YAML/JSON, decoupling validation logic from business logic.
  • Extensibility: Supports custom rulesets via service providers, enabling team-specific validation logic (e.g., enforcing API key formats or database connection constraints).

Integration Feasibility

  • Laravel Ecosystem Native: Designed for Laravel’s config() system, with minimal friction for adoption. Integrates via service provider bootstrapping, leveraging Laravel’s existing DI container.
  • Zero Runtime Overhead: Validation occurs only during config loading (e.g., config('app.timezone')), not on every request, making it lightweight.
  • Backward Compatibility: Non-breaking changes to Laravel’s config system are unlikely, as the package uses public APIs (config(), config_path()).

Technical Risk

  • Validation Timing: Config validation runs after config files are loaded, meaning invalid configs could still cause issues before validation fires. Mitigation: Use booting event to validate early in the request lifecycle.
  • Rule Complexity: Deeply nested or dynamic configs (e.g., generated via config_cache) may require custom rule logic, increasing maintenance overhead.
  • Testing Gaps: Limited test coverage for edge cases (e.g., circular references in config, malformed YAML). Requires unit tests for custom rulesets.
  • Laravel Version Lock: Package targets Laravel 10+ (as of 2026). Downgrading to older versions may require forks or manual adjustments.

Key Questions

  1. Validation Granularity: Should validation apply to all configs or only critical ones (e.g., database.php, services.php)?
  2. Error Handling: How should validation failures be surfaced (e.g., HTTP 500, custom error page, or silent logging)?
  3. Dynamic Configs: How to handle configs generated at runtime (e.g., via config_cache) or loaded from external sources (e.g., environment variables)?
  4. Performance: Will validation impact boot time for large config files? Benchmark with production-like configs.
  5. Custom Rules: What percentage of validation logic will require custom rulesets vs. default rules?

Integration Approach

Stack Fit

  • Laravel-Centric: Optimized for Laravel’s config system, with no dependencies on external stacks (e.g., Symfony, Lumen). Works seamlessly with:
    • Laravel Mix/Valet/Sail: Config validation during local development.
    • Forge/Envoyer: Ensures config validity in staging/production.
    • Laravel Horizon/Queues: Validates config for background jobs (e.g., queue.php).
  • PHP Version: Supports PHP 8.1+ (as of 2026), aligning with Laravel’s minimum requirements.
  • Tooling Compatibility:
    • Laravel Forge/Envoyer: Automate config validation in deployment pipelines.
    • Laravel Pint/CS Fixer: Enforce config file syntax alongside code style.
    • GitHub Actions/GitLab CI: Add validation to CI pipelines (e.g., fail builds on invalid configs).

Migration Path

  1. Assessment Phase:
    • Audit existing config/ files for validation needs (e.g., required fields, types).
    • Identify critical configs (e.g., database.php, mail.php) for initial validation.
  2. Pilot Integration:
    • Install package via Composer: composer require ashallendesign/laravel-config-validator.
    • Publish default rulesets: php artisan vendor:publish --provider="AshAllenDesign\ConfigValidator\ConfigValidatorServiceProvider".
    • Define custom rules in config/config-validator.php (e.g., validate app.timezone is a valid IANA timezone).
  3. Incremental Rollout:
    • Start with non-critical configs (e.g., logging.php).
    • Gradually add rules for database.php, services.php, etc.
    • Use feature flags to toggle validation in staging before production.
  4. CI/CD Integration:
    • Add validation to CI pipelines (e.g., GitHub Actions):
      - name: Validate Config
        run: php artisan config:validate
      

Compatibility

  • Laravel Versions: Tested on Laravel 10+ (2026). For older versions, check for forks or manual adjustments.
  • Config File Formats: Supports .php, .yaml, and .json config files (Laravel’s native formats).
  • Custom Config Loaders: If using non-standard config loaders (e.g., JSON API configs), extend the package’s ConfigValidator class.
  • Environment-Specific Configs: Works with .env-based configs (e.g., config/services.php referencing .env vars).

Sequencing

  1. Pre-Validation:
    • Use Laravel’s booting event to validate configs before they’re used in the request lifecycle:
      use AshAllenDesign\ConfigValidator\Events\ConfigValidated;
      
      ConfigValidated::listen(function () {
          // Early failure if validation fails
      });
      
  2. Runtime Validation:
    • Validate configs on-demand (e.g., in service providers, middleware):
      use AshAllenDesign\ConfigValidator\Facades\ConfigValidator;
      
      if (!ConfigValidator::validate('app.timezone')) {
          abort(500, 'Invalid timezone configuration');
      }
      
  3. Post-Validation:
    • Log validation results for observability (e.g., Sentry, Laravel Log):
      ConfigValidated::listen(function ($event) {
          if ($event->hasErrors()) {
              Log::error('Config validation failed', $event->errors());
          }
      });
      

Operational Impact

Maintenance

  • Rule Updates: Custom rulesets require maintenance if config schemas evolve (e.g., new required fields). Mitigate with:
    • Versioned config schemas (e.g., config/v1/database.php, config/v2/database.php).
    • Automated rule generation from OpenAPI/Swagger specs (if configs are API-driven).
  • Dependency Management: Package updates may introduce breaking changes. Monitor:
    • Laravel version compatibility.
    • PHP version support (e.g., PHP 8.2+ features).
  • Documentation: Maintain a CONFIG_VALIDATION.md in your repo to document:
    • Validated configs and their rules.
    • Custom rule logic and edge cases.

Support

  • Debugging: Validation errors may obscure root causes (e.g., a missing .env var causing a config field to be null). Improve with:
    • Detailed error messages (e.g., point to the exact config file/line).
    • Integration with Laravel Debugbar for visual validation feedback.
  • Support Channels: Direct users to:
    • Package GitHub issues for bugs.
    • Laravel Discord/Forums for architectural questions.
  • SLA Impact: Config validation failures could block deployments. Define:
    • Critical vs. non-critical configs (e.g., database.php vs. logging.php).
    • Fallback configs for non-critical validations (e.g., default values).

Scaling

  • Performance:
    • Boot Time: Validation adds minimal overhead (~10–50ms for large configs). Benchmark with php artisan tinker:
      \AshAllenDesign\ConfigValidator\Facades\ConfigValidator::validateAll();
      
    • Memory: Rulesets are cached; no significant memory impact.
  • Horizontal Scaling: No impact on Laravel’s horizontal scaling (e.g., queues, Horizon). Validation occurs per request/boot.
  • Distributed Configs: For microservices or multi-tenant apps:
    • Validate tenant-specific configs (e.g., config/tenants/{id}.php).
    • Use package’s validateFor() method to scope validations.

Failure Modes

Failure Scenario Impact Mitigation
Invalid config at boot App crashes (500 error) Use booting event to fail fast; provide clear error pages.
Missing .env variables Config validation fails Validate .env files separately (e.g., with vlucas/phpdotenv-validator).
Circular config references Infinite loops in validation Add recursion depth limits in custom rules.
Custom rule errors Silent failures or crashes Wrap custom rules in try-catch; log errors to Sentry.
Package update breaks compatibility Validation fails post-update Test updates in staging; use composer why-not to debug dependency conflicts.

**Ramp-Up

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.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours