Forums / Discussions / loading external libraries in extensions

Wednesday 06 October 2010 4:38:01 am - 10 replies

Introduction

Often you need to include external 3rd party libraries or your own libraries in the extensions (like for example a SOAP library). The problem comes when you have to include the same library in several extensions.

Here is how to do it without having to copy the same library in every extension directory.

» Read full blog post

Author Message

Quoc Huy Nguyen Dinh

Friday 08 October 2010 6:28:26 am

Put the library in its own extension, maybe?

Marko Žmak

Monday 11 October 2010 1:32:25 am

Yes Quoc, that's exactly what's described here.

Note that you can also load external libraries that are not inside your eZ installation, but that's a little bit more advanced usage.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Quoc Huy Nguyen Dinh

Monday 11 October 2010 8:20:29 am

Hi Marko

Bad on me, I misread the post, I thought you were asking how to do it.

I didn't realize this is a tutorial, very interesting, I'm reading it now

Nicolas Pastorino

Monday 11 October 2010 8:28:30 am

This post rocks, keep up Marko !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Marko Žmak

Moderated by: Nicolas Pastorino

Monday 11 October 2010 4:32:44 pm

Thanks for the feedback.

A good enhanchement for eZ would be the possibility to load external libraries that are not inside the extension directory (and even outside the eZP installation), but without the need for such advanced usage as described in this blog post.

For example, to have a possibility to specify a parameter like this:

php bin/php/ezpgenerateautoloads.php --external-dir=/path/to/your/external/library

would be really nice.

This would be very usefull when you have several eZ installations on the same server that all have extensions that use the same external libraries.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Nicolas Pastorino

Tuesday 12 October 2010 2:09:20 am

Hi Marko,

Have you taken a look at the end of the <ezp-root>/config.php-RECOMMENDED file ? The external loading mechanism described is maybe what you are looking for.

Cheers !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Marko Žmak

Tuesday 12 October 2010 5:10:17 am

Yes Nicolas, the part of the config.php you described is basically the same thing I described here in the "For advanced users" paragraph.

What I'm proposing is to add a parameter to the ezpgenerateautoloads.php script that will allow to autoload external libraries in an easy way without having to create your own autoload function and register it with spl_autoload_register().

If there's already autoload functionality in ezpgenerateautoloads.php for extensions, why not reuse it and add the ability to autoload any external library?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Nicolas Pastorino

Wednesday 20 October 2010 5:12:30 am

HI Marko,

This idea is worth reporting there http://issues.ez.no/ezpublish , i'd say.

Cheers !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Marko Žmak

Saturday 08 January 2011 2:15:45 pm

OK, I've reported it on the tracker:

http://issues.ez.no/IssueView.php?Id=17826

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Nicolas Pastorino

Monday 10 January 2011 6:30:23 am

"

OK, I've reported it on the tracker:

http://issues.ez.no/IssueView.php?Id=17826

"

Excellent, thanks Marko !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

You must be logged in to post messages in this topic!