Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: autoconfigure interfaces #55013

Draft
wants to merge 1 commit into
base: 12.x
Choose a base branch
from
Draft

Conversation

soyuka
Copy link

@soyuka soyuka commented Mar 13, 2025

The idea of auto-configurable services is that you setup some interfaces for auto configuration and they get automatically tagged by the Laravel container. For example, let's take this interface:

interface ProviderInterface {}

We want this interface to be automatically tagged in the container, a Laravel component would have something like this:

$app->make(LibraryProvider::class, function(Application $app) { 
    return new Provider($app->tagged(ProviderInterface::class)); 
});

$app->autoconfigure(ProviderInterface::class);

With this feature, in userland developers don't need to do anything as these services are automatically discovered and tagged.
We implemented this into API Platform and @TomasVotruba suggested I propose this to the Laravel framework.

Do you think that this is something we'd like to see inside the Laravel framework?

@taylorotwell taylorotwell marked this pull request as draft March 13, 2025 14:55
}

try {
require_once $sourceFile;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely going to be an issue if the discovered file is a blade template or a pest unit file. Still looking to improve that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant