What does the make() method do in Laravel?

Laravel’s make method is used to create an instance of a class or interface.While creating an instance with make method Laravel will automatically inject all dependencies of class that is defined in it’s constructor. E.g. an instance of the Mailer class would be automatically injected in below code.

namespace AppServices;

use IlluminateMailMailer;

class MyService
{
public function __construct(Mailer $mailer) {
$this->mailer = new Mailer;
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *