by Devin Yang
(This article was automatically translated.)

Published - 6 years ago ( Updated - 6 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


laravel

Add fields and update Laravel at the same time

I was told by my friends, Murphy's Law, that promotion is always so difficult, of course I have to show him how smooth I am, I'm not afraid. I also added a column by the way.

laravel,sftp

Use Laravel's Storage SFTP Drvier for remote file upload

Why do I separate the front and back of the website? My idea is very simple, that is to rely on a set of background to control all the website data in the foreground. Assuming that the front-end website is a pure marketing website, it is nothing more than the subject content, just like the article above, without any particularly complicated logic. Therefore, it is enough to set up the backend database and connect different frontends. Then there is the last question, how can my backend HTML editor post pictures directly to the frontend? Laravel's Storage SFT Driver is a good antidote.