Support the ongoing development of Laravel.io →
Configuration Packages Architecture
Last updated 1 year ago.
0

There are several methods you could use. One is to create a Facade and access your utility class that way, however my preferred method is to have the class injected via my class's __construct() method, like so:

Class MyClass
{
    protected $utilityClass;

    public function __construct( UtilityClass $utilityClass )
    {
        $this->utilityClass = $utilityClass;
    }
}

Last updated 1 year ago.
0

thanks, in which directory it will be positioned?

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ocraton ocraton Joined 18 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.