include a file in laravel controller
require_once __DIR__ . '/../app/Utilities/FileName.php';
include a file in laravel controller
require_once __DIR__ . '/../app/Utilities/FileName.php';
include a file in laravel controller
If you have a custom file containing some classes/functions that need to be\
loaded for every request, you need to make sure its added to the autoloader.
In your composer.json add the following in your autoload section:
"autoload": {
"files": [
"path/to/your/File.php"
]
}
OR
First, make sure you have a namespace declaration at the top of your included
file - say namespace Your\Namespace. In order to avoid conflicts, you need
to explicitly tell PHP which class you mean when you reference it in the code. You mentioned your file contains a Response class that also exists in Laravel. In order to be able to use both, you need to alias one of them:
use Illuminate\Http\Response as LaravelResponse;
use Your\Namespace\Response;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us