Skip to content

[DX] Better error on bad service class name #11301

@weaverryan

Description

@weaverryan

This may be easy, or may be hard :).

If you create a service and specify a bad class name, you'll get an error at runtime (when you use the service) similar to:

PHP Fatal error: Class 'Knp\FooBundle\Security\Voter\CourseVoter' not found in /path/to/project/app/cache/dev/appDevDebugProjectContainer.php on line 3832

To a beginner, the appDevDebugProjectContainer is confusing. I'd love to say something like:

Class "Knp\FooBundle\Security\Voter\CourseVoter" not found. Check the spelling on the "class" configuration for your "course_voter" service.

This could be easily done in a compiler pass. My concern is side effects :). Is it possible that a class will not be available at compiler time but will be available at run-time? If a compiler class won't work, we'd need to add class_exists in the compiled code, which would be a bummer.

The advantage is clear, the solution might be harder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXDX = Developer eXperience (anything that improves the experience of using Symfony)DependencyInjection

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy