Support the ongoing development of Laravel.io →
posted 9 years ago
Architecture
Last updated 2 years ago.
0

Hi, you need to add your repository to the IoC container using a Service Provider.

See the App::bind() function for this feature here: http://laravel.com/docs/ioc#basic-usage

Remember add your Service Provider to the app.php providers list.

For Service Provider see: http://laravel.com/docs/ioc#service-providers

Hope it helps you.

Last updated 2 years ago.
0

Hey CodeATbusiness,

But isn't the service provider more of an optional step to abstract even further? I mean, shouldnt the repository work "on it's own"?

Maybe I misunderstood something here :)

Last updated 2 years ago.
0

You're right; the service provider isn't required.

Instead of the psr-0 option in composer.json, try to adjust the autoload > classmap section like this:

"autoload": {
    "classmap": [
        "app/commands",
        "app/controllers",
        "app/models",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php",  // Don't forget the comma here :)
        "app/Yourday"
    ]
},

This won't give you the psr standard of course, but it should let us know if we're missing something else.

Last updated 2 years ago.
0

Reached said:

Hey CodeATbusiness,

But isn't the service provider more of an optional step to abstract even further? I mean, shouldnt the repository work "on it's own"?

Maybe I misunderstood something here :)

You're correct, you only need to use a service provider if you're binding an interface to an implementation. Do your filenames and folders match the namespace exactly, including capitalization?

Last updated 2 years ago.
0

Sorry friends, I was thinking that you need to bind to an implementation as thepsion5 commented us.

Thanks for your reply.

Last updated 2 years ago.
0

Shouldn't psr-0 be like

"psr-0": {
       "Yourday": "app/"
},

And psr-4:

"psr-4": {
    "Yourday\\": "app/Yourday"
}

And don't forget to "composer dump-autoload"

Last updated 2 years ago.
0

Seems like you solved my problem, thanks guys!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Reached reached Joined 27 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.