CodeIgniter Forums
Loading a plugin within a library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Loading a plugin within a library (/showthread.php?tid=33247)



Loading a plugin within a library - El Forum - 08-19-2010

[eluser]oste15[/eluser]
I was wondering if it is possible to load a plugin inside of a library file.

When I try to load my custom plugin inside my custom library I get the following error
Fatal error: Call to a member function plugin()

I also get this warning
Message: Undefined property: ApiCall::$load

The only solution I see is to autoload the plugin, but that is not the best solution.


Loading a plugin within a library - El Forum - 08-20-2010

[eluser]WanWizard[/eluser]
First of all, don't use plugins. They are deprecated and will no longer be supported in CI 2.0. Use a helper instead (they're the same thing anyway)

How do you load your library? It looks like $this->load doesn't work in your library, so the plugin is not loaded, and therefore the call to the plugin fails.

$this->load doesn't work in constructors, so use
Code:
$CI =& get_instance();
$CI->load->plugin('plugin');



Loading a plugin within a library - El Forum - 08-20-2010

[eluser]oste15[/eluser]
Thanks, gotta remember about the old get_instance reference.

It is also interesting to note that the plugins are being deprecated. Like you mentioned there is really no difference between plugins and helpers. The user guide mentions that helpers should not be OO, but that is silly and is obviously being changed.

Thanks again.