![]() |
Trouble loading getID3 library - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Trouble loading getID3 library (/showthread.php?tid=90969) |
Trouble loading getID3 library - Pardner - 05-29-2024 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'; 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){ 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){ but now I get another error: Code: Class "GetID3\Exception" not found 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 RE: Trouble loading getID3 library - InsiteFX - 05-29-2024 Did you try to autoload the library using the Classmap? CodeIgniter4 User Guide - Overview - Autoloading Files - Classmap RE: Trouble loading getID3 library - Pardner - 05-30-2024 Code: If you use third-party libraries that are not Composer packages and are not namespaced, you can load those classes using the classmap: Adding the 'non-composer' getID3 library to the classmap fixed the issue. Thank you InsiteFX RE: Trouble loading getID3 library - InsiteFX - 05-30-2024 Your Welcome. |