Загрузка страницы

Creating Custom Helpers in a Laravel Project

Creating Custom Helpers in a Laravel Project - Laravel - The PHP Framework For Web Artisans
👍 Subscribe for more tutorials like this: https://www.youtube.com/channel/UCAo0zsTJa1Yu7MPNBhjCg7Q/

As you might know, laravel has many built-in helper functions that you can call anywhere within your application.
This helper includes arrays, file paths, strings, and routes, and others.

But as per application requirement, you want to create your own custom helper functions in laravel to avoid repeating the same code.
So that uses the DRY principle which means "Don't Repeat Yourself," a basic principle of software development aimed at reducing repetition of information/code.
In order to create a custom helper first, we have to define it and then make it autoloaded so that we can use custom helper anywhere in the application.

There are a few options where you can organize the location of your helper file
1.app/helpers.php
2.app/Http/helpers.php
3.app/Helpers/Helper.php

Run the artisan command

composer dump-autoload
Now your helper file will be automatically loaded in your Laravel application.

⭐️ Want to learn more from me? Check out these links:

Blog: https://coderuck.com
Linkedin: https://www.linkedin.com/company/coderuck
Facebook: https://www.facebook.com/coderuck

Видео Creating Custom Helpers in a Laravel Project канала Coderuck
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
7 января 2021 г. 1:06:36
00:12:15
Яндекс.Метрика