Welcome Guest, Not a member yet? Register   Sign In
Trouble implementing getID3 custom library

I'm trying to use getid3 as a library. It will not load for some reason. The directory structure makes it a bit weird, which may be the problem. It is set up as getid3/getid3.php. That's the file I need to load, as there are a bunch (like 30!) other files in that same directory that may or may not get loaded. Can I just do this: $this->load->library('getid3/getid3'); ? I know I can for views but not sure for loading libraries.

There may be some naming problems. Any help greatly appreciated. It is currently in my /app/libraries/ folder, and as you can see I have a custom layout of folder something like:

- app
-- libraries
-- etc...
- index.php
- sys161

Thanks in advance!

Could really use help with this if anyone has a chance. I need it for work, and have no idea how to proceed.

[eluser]Pascal Kriete[/eluser]
The loader doesn't load libraries in subfolders.

I would use the traditional php approach here.
Put the getid3 folder in your application folder.

Then just load it the old-school way:
And instantiate the class:
$getID3 = new getID3;
Hope that helps/works.

[eluser]Elliot Haughin[/eluser]
Alternatively, take the getid3.php and put it straight in your libraries directory, then go through the code and make sure it's referencing any of its dependent files as getid3/filename.php


Thanks guys. I'll probably use inparo's solution but Elliot's isn't a bad idea either. Not allowing nested library files seems rather arbitrary since the load class allows folders for other types of sources.

As a followup, I got this working as Elliot mentioned by making the following changes to the getid3.php file:
* renamed it Getid3.php, moved to /application/libraries/Getid3.php
* left all the other files in their getid3 folder, and put that, too, in /application/libraries/
* added the following code about class Getid3 in the above file:
if (!defined('GETID3_INCLUDEPATH')) {
    foreach (get_included_files() as $key => $val) {
        if (basename(strtolower($val)) == 'getid3.php') {
            define('GETID3_INCLUDEPATH', dirname($val).DIRECTORY_SEPARATOR.'getid3'.DIRECTORY_SEPARATOR);

This will set GETID3_INCLUDEPATH so that it is not set later in the class.

From there, you can do a simple $this->load->library('Getid3'); and use it as $this->getid3->method();

Thanks Scott and Elliot.

If you are using the latest version of getid3 (php5) and you want use it like Scott way.

change this line
$this->include_path = $include_path = dirname(__FILE__) . '/';

into this:
$this->include_path = $include_path = dirname(__FILE__) . '/getid3/';

easy? no?

PD: without Scott code!

Theme © iAndrew 2016 - Forum software by © MyBB