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

How do I upgrade the backend to Lravel 5.5

At the beginning, my background was a framework created by myself, which also uses MVC architecture, database connections and environment configuration files made by myself, including my own template syntax, until I want to support Restful, I have an idea, why should I rewrite the same function myself after others have written it, would it be better to write it out? So I started to use the framework, At the beginning, Slim was adopted mainly because it supports a lower version of php, but because Slim's twig templates are not as easy to use as Laravel's blade template...

laravel, livewire

livewire important notes

Before starting your Livewire journey, here are three basic considerations about public properties: 1. The property name must not conflict with a property name reserved for Livewire (such as $rules or $message) 2. Store in Data in public properties is visible to front-end JavaScript. Therefore, you should not store sensitive data in it. 3. Properties can only be JavaScript-friendly data types (string, integer, array, boolean), or one of the following PHP types: Stringable, Collection, DateTime, Model, EloquentCollection.

laravel,blade

Laravel 5.5 make:model's -a parameter and Blade version chunk function introduction

Do you not know what the make:model -a parameter is? This video will briefly introduce the actual operation process. And use the chunk function in the Blade set to end.