I'm using getid3 library with a Laravel project. I created a folder called "includes" in the app/ directory and inside it a folder called getid3 which contains a bunch of php files, I included the getid3.php file which resides in that directory. Here is the file content along with the library on Github:- https://github.com/JamesHeinrich/getID3/blob/master/getid3/getid3.php
In the controller, when I try to instantiate the getID3 class which is defined in that file, I get following error:-
FatalErrorException in ApiV1.php line 217:
Class 'App\Http\Controllers\getID3' not found
Here is the code block in the controller in which I'm trying to instantiate the class
ob_start();
if ($fp_output = fopen($FilenameOut, 'wb')) {
ob_end_clean();
// Initialize getID3 engine
$getID3 = new \getID3;
foreach ($FilenamesIn as $nextinputfilename) {
$CurrentFileInfo = $getID3->analyze($nextinputfilename);
if ($CurrentFileInfo['fileformat'] == 'mp3') {
How to solve this error ?
Your class has been defined in the root namespace, you need to add a \
before the class name. Otherwise php will think it is in the same namespace as the current class, currently App\Http\Controllers
.
You should do something like this:
$id3 = new \getID3;