Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DDSameera's avatar

What is recommend way to keep StudentService + StudentFacade in laravel ?

I saw several tutorials are recommend to maintain façade file using via on customservice provider with service container bindings. I didn't follow up it.

So I follow up this way to maintain my StudentService class. Is this best practice ? or Not . if NO, please explain little bit.

composer.json

  "autoload-dev": {
        "psr-4": {
            "Domain\": "domain/",
            "Tests\": "tests/"
        }
    },

StudentFacade.php

class StudentFacade extends Facade{

    protected static function getFacadeAccessor()
   {
       return StudentService::class;// TODO: Change the autogenerated stub
   }


}

StudentService.php

class StudentService
{
 
    public function index()
    {
        return Student::all();
    }
}

StudentController.php

class StudentController extends Controller
{
   
    public function index()
    {

        $students = StudentFacade::index();
        return view('student.index', compact('students'));
    }
}
0 likes
4 replies
martinbean's avatar

@DDSameera Dude, don’t bump your question after a few hours. You’re no important than anyone else.

It’s the weekend. People tend to enjoy themselves rather than wait for you to post a thread.

Please or to participate in this conversation.