DEV Community

Bhanu Pratap Singh
Bhanu Pratap Singh

Posted on

Laravel Create Custom Class

First we will create custom class file inside laravel project app/Classes If Classes folder doesn't exist inside app folder then create it manually.


Second step is to create your class file, I have created like SendSms.php inside your app/Classes folder.

Third step define your class code.


Finally you have created your custom class now how to access custom class method.?

Define use App\Classes\SendSms; on the top of your controller.Then only you can able to access custom class method.


@Other Reference


Top comments (1)

zubairmohsin33 profile image
Zubair Mohsin

Hi there, just noticed that env() function inside class.
Consider refactoring it to a configuration variable and then use config() to access that value.
By doing this, you can leverage configuration caching in production.