views:

44

answers:

2

Hi everyone !

I'm beginning a website using Kohana Framework, and I couldn't find how to include external libraries "the proper way". I want to use the phpFlickr library to allow my website to interact with flickr, and I was wondering if there was a better way to include the files than :

require_once("path/to/phpFlickr.php");
// Fire up the main phpFlickr class
$f = new phpFlickr($key);

It's OK to do it that way I guess, but if I could say to Kohana : "the phpFlickr files are there, go get them on your own when you need it", it would be better.

Anyone can help me with that ?

Thanks.
Regards from France ;)

+1  A: 

You can make a flickr folder in modules, create an init.php file in there and do something like this;

require_once Kohana::find_file('folder','phpFlickr');

Of course, you'll first have to enable "flickr" module in your bootstrap.

The better way would be to define a custom autoload method for flickr classes only so it's loaded only when it's actually needed.

Kemo
+1  A: 

We use it in the same way as detailed here. So, like the following:

$path = Kohana::find_file('vendors', 'flickr/phpFlickr');
if($path) {
    ini_set('include_path',
    ini_get('include_path') . PATH_SEPARATOR . dirname(dirname($path)));
    require_once 'flickr/phpFlickr.php';
}   
Steerpike
i'm not sure if changing `include_path` is really necessary
zerkms
Yeah I guessed it was like that, but the aticle used Zend so I wasn't totally sure. Thanks for confirmation !
Squ36

related questions