Support the ongoing development of Laravel.io →
IOC Architecture Testing

Hello All,

I am using PHPSpec to test my classes, therefore I've been trying to inject everything via constructor, or setter injection instead of using Facades everywhere. However my problem is that I couldn't figure out a proper way of injecting the Config Repository. I tried to inject \Illuminate\Config\Repository in my constructors but it always produced an error in the Container. The error is: Target [Illuminate\Config\LoaderInterface] is not instantiable.

I found this relevant article: http://forumsarchive.laravel.io/viewtopic.php?id=15810. There is a work around for this. I am just wondering whether there is a better of doing things.

Last updated 2 years ago.
0

you could install benconstable/phpspec-laravel and then all Laravel aliases will become available in your specs

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

liamqma liamqma Joined 9 Apr 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.

© 2025 Laravel.io - All rights reserved.