by Devin Yang
(This article was automatically translated.)

Published - 5 years ago ( Updated - 5 years ago )

In Laravel's framework, it contains quite a lot of PHP functions (php functions), called helpers.
https://laravel.com/docs/5.6/helpers
So how do we customize our own helper in Laravel? It's actually quite simple..
Just add files in autoload in composer.json.
 "autoload": {
        "files": [
            "app/ow_source/_functions.php"
        ],
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/",
            "Ow\\": "app/ow_source/class",
            "Ow\\Model\\": "app/ow_source/model"
        }
    },
In this way, we can call our function anytime and anywhere.

Tags: laravel

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


dlaravel

Super easy to use HTML to PDF kit mpdf introduction

During development, will it be necessary to output HTML to PDF? This video introduces how to output PDF on the screen through the mpdf library of php.

wordpress, d-laravel, docker, docker-compose

How to install Wordpress with D-Laravel

An 8-minute teaching video, introducing the installation of Wordpress on D-Laravel. D-Laravel is a docker-compose Laravel framework development environment, but it does not mean that it cannot be used to install other things. This video introduces the use of D-Laravel to install non-Laravel PHP projects, You can learn the usage of related instructions on D-Laravel: ./create --host usage, docker-compose up -d and ./console mysql usage, The database connection setting method after D-Laravel v1.0.0.

laravel,trait,php

My Browser Trait, webp image file support function detection and whether it is a mobile phone detection

I believe that many people are familiar with PHP trait, because Laravel can be seen everywhere, but I still write it and share it with those who are destined. PHP trait allows two different CLASS to use the same method. It not only reduces the complexity, but also allows the code to be reused. So it should be very convenient to put a Browser series function on Laravel's ViewServiceProvider 😝