Welcome Guest, Not a member yet? Register   Sign In
using different php script with codeignter
#1

[eluser]immi[/eluser]
Hi all!

I am new to codeignter and i want to know that if we want to use a script like getid3
Site Link which will be based on many classes and thats script will use include functions for all type of classes can i use it as plugin? or as lib?

Kindly reply!

Thank You!
#2

[eluser]ranjudsokomora[/eluser]
immi,
You should be able to convert those classes to a CodeIgniter plugin.
You can read about that here Plugins: CodeIgniter User Guide

The biggest thing to be careful of is collision of class names. You shouldn't have a problem with the applications you mentioned but just keep an eye out.
#3

[eluser]immi[/eluser]
Hi Ranj!

What i see here is plugin only needs to be ended with _pi.php so all the other depending classes should be ended with _pi.php (which will be on used in main class)?
#4

[eluser]ranjudsokomora[/eluser]
Hello immi,
I would suggest following a non CodeIgniter standard for the getID3 plugin.
I would create a folder under ./system/plugins called "getID3" (without the quotes)
Extract the downloaded getID3 archive to this new folder.

Then in ./system/plugins create a getid3_pi.php file
Place this in it:
Code:
<?PHP
// Code Example Taken From: http://php.net/manual/en/language.constants.predefined.php
if(!defined('__DIR__')) {
    $iPos = strrpos(__FILE__, "/");
    define("__DIR__", substr(__FILE__, 0, $iPos) . "/");
}
$directory = __DIR__;
$include_directory = $directory."/getID3/";
INCLUDE_ONCE($include_directory."getid3.php")

Then in your controller you would place this code
Code:
$this->load->plugin('getID3');

You should now be able to use all of the getID3 class(es) inside of your controller by calling their function.

Ex.
Code:
$mp3info = GetAllMP3info(<filename>);
#5

[eluser]Daniel Moore[/eluser]
I'd recommend doing this as either a helper or library, as plug-ins are removed in CodeIgniter 2.0.
#6

[eluser]ranjudsokomora[/eluser]
Daniel Moore,
I wouldn't suggest converting getID3 to a helper, as you would have to rebuilt all the include links in each file, but in CodeIgniter 2.0 you could built getID3 as a package, or convert it to a library.




Theme © iAndrew 2016 - Forum software by © MyBB