Reputation: 5441
I've created a simple class Car
which takes 2 arguments at its constructor, Wheels
and SteeringWheel
both of those arguments are another objects.
When I type App::make('Car')
, as I recall, it should instantiate a Car
object and do the dependency injection on it's own even without binding the Car
class. However, when I do that, I get an error: ReflectionException: Class Car does not exist
even tho I've used the Car
namespace by doing: use Acme\Car
at the top of the page.
However, if I provide to the make
function the full "path" to the Car
class, it works: App::make('\Acme\Car');
Any idea how I can make it work even if I type Car
only?
Upvotes: 0
Views: 896
Reputation: 465
The App::make()
function doesn't use the includes at the top of the page, it creates a class from the string you provide. If you want to only use Car
, remove the namespace Acme
from the Car
class.
Upvotes: 2