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


docker, d-laravel, docker-compose, laravel

docker-compose loads multiple configuration files

We will use docker --network to establish multiple container interconnections, but if there are four containers, Is it necessary to issue docker run instructions for different containers four times, kill me, This article introduces the establishment of multiple containers at one time through the yaml file definition of docker-compose. Learn how to load multiple configuration files with the dokcer-compose -f parameter.  

laravel

Facebook test user

Is there anyone who uses OAuth for website user login like me? There is a "test user" on the Facebook developer page. It can be used to test whether the function of Facebook is normal, Because when the website moved to Google’s GCE, for some reason, I actually posted one more in the $fillable array of Laravel’s User model~, Normally the program works fine, but when a new user logs in, an error is shown to you. I keep hearing people say that I can't log in to this website to leave a message. I want to say that I am very normal. @@ After using the test user test today, ha, I found that the login function on my website has been broken for a long time.

laravel

In Laravel 5.5, easy to use basic routing

Especially for friends who are studying SEO, we should know that sometimes we need to redirect 301 pages, which is provided in Laravel 5.5 The function of Route::redirect is quite simple. In addition, using Route::view is also very useful for the layout of static pages.