Category: Laravel, PHP

Sometimes, you will stumble on some functionalities that will be required in so many different parts of your application, then will wonder why you have to keep duplicating this same lines of codes instead of implementing it once and having it reused. Create a folder Helpers in your Laravel app directory. Create your helper file in your Laravel app\Helpers folder and give it any name of your choice, we will call the file helper.php in this article. Load the file app/Helpers/helper.php up in your composer.json file. After adding that to your composer.json file, run the following command: And that is it, you can declare your functions, classes and/or variables within the helper.php file and it will be available for use in all controllers, views and models.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners