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

Fetching a Service from Container - Backslash mismatch #265

Open
14nd90 opened this issue Oct 24, 2024 · 1 comment
Open

Fetching a Service from Container - Backslash mismatch #265

14nd90 opened this issue Oct 24, 2024 · 1 comment

Comments

@14nd90
Copy link

14nd90 commented Oct 24, 2024

In my config/app.php I was registering a service as per the docs

 'services' => [
    ...
    '\App\Services\UserService',
],

But when it came to getting the service, it was returning NULL
$this->user_service = tr_container(\App\Services\UserService::class);

This seems to be because when registering the service, the string provided in config is used as they key in the list, whereas when resolving, the ::class keyword returns the class path without the preceding backslash. Everything works as expected when defining the service without the preceding backslash in config. But I would expect the docs to highlight this, or for there to be a some consistency in key names when registering services.

@kevindees
Copy link
Member

@14nd90

I'll see what we can do.

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

No branches or pull requests

4 participants
@kevindees @14nd90 and others