Jump to content
fivestringsurf

Composer autoloading inconsistencies?

Recommended Posts

I've been using composer and like the idea of having managed libraries/dependencies in php.

I'm having trouble understanding how to call libraries with autoloading.  Some of the package authors give great directions and some don't.  Things seem very inconsistent which is really annoying.

 

For example I'm using this image library like this:

use Intervention\Image\ImageManager;
$imgMan = new ImageManager(array('driver' => 'gd'));
//etc...

Awesome! But I can't figure out how to do something similar with firephp and mpdf (namespacing)?

 

I figured out that these do work:

$firephp = FirePHP::getInstance(true);
$mpdf = new mpdf();

But, why all the inconsistencies and different ways of doing things?  I'd like to keep everything neat and namespaced all in a similar way.

 

Can anyone offer some advice?

 

Share this post


Link to post
Share on other sites

That's just the way the author(s) designed and wrote their code: ImageManager uses namespaces, FirePHP uses a singleton pattern, and mpdf doesn't use namespaces. Sometimes there's history behind the decisions, sometimes there's history to the project itself that predates some PHP features or best practices.

 

Not really much you can do about it.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.