Welcome Guest, Not a member yet? Register   Sign In
Trouble loading getID3 library
#1

First post. I've deployed a couple sites running a CI framework, but now I am creating my first from scratch so bare with me. 



I would like to determine the length of a audio/video file after a user upload and a quick search online landed me with the getID3 library. Downloadeded the library (github) and placed it in my ThirdParty directory, but I am having trouble creating a getID3 object.



1) I created a test script my public_html.

Code:
require '../app/ThirdParty/getid3/getid3.php';
$getID3 = new getID3;
if(!file_exists("test.flac")){
    exit("File not found");
}
$file = $getID3->analyze("test.flac");
$duration_string = $file['playtime_string'];
echo $duration_string;

The script runs as expected, it outputs the length of the audio file. Great!



2) I tried loading the getID3 library from my controller 'app/Controllers/Job.php' (Note: showOrderForm functions as normal without getID3 and outputs a form for the user): 



Code:
private function showOrderForm($job){
    require_once APPPATH . "/ThirdParty/getid3/getid3.php";
    $getID3 = new getID3;
    // ...
}


But when I run the controller (while in development mode) I get the following error:

Code:
Class "App\Controllers\getID3" not found


Why is ci4 trying to load a controller?



3) I noticed that the getid3.php does not delcare a namespace, so I added 'namespace GetID3;' to the top of their script. Then modified my controller to include the namespace:



Code:
private function showOrderForm($job){
    require_once APPPATH . "/ThirdParty/getid3/getid3.php";
    $getID3 = new GetID3/getID3;
    // ...
}


but now I get another error:



Code:
Class "GetID3\Exception" not found
class getid3_exception extends Exception
{
    public $message;
}


So it looks like adding a namespace broke the getID3 library. Is there anyway to load this library without going through and adding namespaces to all their files? I understand this may not be a ci4 issue, but their library works outside ci4. I also know that the getID3 library does not follow ci4's naming convention with the Capitization of the class name, would this br the problem (I've tried unsucessfully renaming class names and direcory name).

Any help would be appreciated. Thanks!
~Pard
Reply


Messages In This Thread
Trouble loading getID3 library - by Pardner - 05-29-2024, 06:29 AM
RE: Trouble loading getID3 library - by InsiteFX - 05-29-2024, 11:33 PM
RE: Trouble loading getID3 library - by Pardner - 05-30-2024, 07:43 AM
RE: Trouble loading getID3 library - by InsiteFX - 05-30-2024, 09:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB