don't include it, just use it
At the beginning of your controller
<?php
namespace App\Http\Controllers;
use App\Functions\nusoap;
use App\Http\Controllers\Controller;
class FooController extends Controller
{
[...]
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have an php file(SOAP connection) with multiple classes in it that I would like to import into a controller
I've used
The file is located at app/Functions/nusoap.php
require_once(app_path() . '\Functions\nusoap.php');
$client = new nusoap_client('URL', true);
include_once(app_path() . '\Functions\nusoap.php');
$client = new nusoap_client('URL', true);
Everytime I get the following error
Class 'App\Http\Controllers\nusoap_client' not found
The nusoap_client class is present in the PHP file I included and/or required.
What am I doing wrong?
It is a file that has multiple classes @Vilfago so aliasing it will not work
The require approach should work, but since it is in the global namespace, you should preceed the class name with a \:
$client = new \nusoap_client('URL', true);
Please or to participate in this conversation.