Hi folks is there a way I can include in my plugin a custom library?
include('library/run.php');
Hi folks is there a way I can include in my plugin a custom library?
include('library/run.php');
Yes, but you have to do it with require_once()
Yes, you can put it wherever you want as long as the path points correctly.
Remember that until this sentence is executed, this library is not available.
It is not a good practice to put it in init.php of your plugin if it is not essential because the init.php of all plugins are executed when loading any OxWall page and maybe in that page nothing of your plugin is needed and this affects unnecessarily the speed of the whole web and the memory consumption.
If the library has already been read, successive attempts to read it do not consume memory or time.
I have seen a lib folder in other plugins so maybe make a lib folder and put it in there. I am looking at this plugin now that has a lib folder, i think oxwall already excepts the lib folder without using include. I will let you know after i poke around a bit in the plugin.
Nope no include required that i can see, you just put it in a lib folder in your plugin and the file should be in class format and then you can refer to it.
Hi folks! Dave baby could you help me out I cant seem to make this work man. Where should I put the lib directory? Also class name should it be an instance of the plugins key like other class files?
Im trying to add this library:
$getID3 = new getID3;
Class 'getID3' not found!
Where or how did you define your class, do you have a class with that name?
for example in classes folder do you have a file for that class with class name
class PLUGINNAME_CLASS_Getid3
remember that uppercase matters in class names
Then in your activate file you can have something like
if(class_exists('PLUGINNAME_CLASS_Getid3'))
{
require_once dirname(__FILE__) . DS . 'classes' . DS . 'getid3.php';
$getID3 = new PLUGINNAME_CLASS_Getid3();
$getID3 = whatever function name in that class();
}
When you said library i was thinking you wanted to add third party library files.