IPBWI for Fuel PHP
#1
Posted 10 May 2011 - 09:02 PM
I've made some major enhancements to IPBWI and the way it loads classes. My goal here was to adapt the Fuel PHP Coding Standards (in particular, the Naming Conventions). Not only is this good for organization, but it makes the library 100% compatible as a package with Fuel PHP! You can find the code in my repository on GitHub.
Unfortunately at the moment it's only compatible with PHP 5.3+, as I've introduced namespaces into the library. I'll probably make a 5.2 version of the changes I have done and add them to a 5.2 branch.
#2
Posted 10 May 2011 - 09:06 PM
#3
Posted 10 May 2011 - 10:37 PM
Edit: I fixed the cache initialization bug, which is the only one I've found so far.
I'd love it if someone could give it a download and let me know if they come across any issues. I updated the examples so they should be working with this new version.
IPBWI seems pretty stable, so for people who are running PHP 5.2, we can probably just have them use the current version and introduce a new version which only works with 5.3 (and has my changes). I see no reason why we can't just make a 3.1 version and make that PHP 5.3+.
I'll still look in to backporting the stuff I've done so far. I have tentative plans to completely overhaul the system and make it far more memory efficient, etc, cause right now it's using about 18mb of memory just to init.
Edited by neen, 10 May 2011 - 11:00 PM.
#4
Posted 11 May 2011 - 01:34 AM
neen, on 10 May 2011 - 10:37 PM, said:
that's the plan
#5
Posted 11 May 2011 - 05:56 AM
$config = new Ipbwi_Config($config = array('key' => 'foo'));
echo $config->key;
$config->key = 'value';
echo $config->key;
#6
Posted 15 May 2011 - 10:18 AM
private $loaded_classes = array();
public static function instance() {
if(!isset(self::$instance)) {
$class = __CLASS__;
self::$instance = new $class;
}
return self::$instance;
}
public function __get($name){
$name = ucfirst($name);
if(!array_key_exists($name, $this->loaded_classes)) {
if(!class_exists($name)) {
$classname = '\Ipbwi\Ipbwi_'.$name;
$this->loaded_classes[$name] = $classname::instance($this);
}
}
return $this->loaded_classes[$name];
}
This also means the code to set the config is a bit different now:
\Ipbwi_Config::instance()->set_config($config);
Still not done converting everything over, but when I am I'll push to my git repo. I'll be making a new 3.1 branch for this, and it'll be the default from now on. All of this occurs automatically behind the scenes - all you need to do is simply call $ipbwi->foo and it will instance the foo class for you using the autoloader and the magic __get() method. You can obviously chain methods as seen above.
Edited by neen, 15 May 2011 - 10:40 AM.
#7
Posted 15 May 2011 - 05:46 PM
when you're fnished, I'm looking forward to a benchmark wether your new class loader is faster or not,
Thx,
Matthias
#8
Posted 15 May 2011 - 09:32 PM
Matthias Reuter, on 15 May 2011 - 05:46 PM, said:
when you're fnished, I'm looking forward to a benchmark wether your new class loader is faster or not,
Thx,
Matthias
Also, since the majority of the classes extend the base IPBWI object, we shouldn't need to pass the IPBWI object around when instantiating those classes, and it's probably a waste of memory to do so (though it is possible there is a legitimate reason for doing so).
Edit: seems like I was right, I've just set the cache class to the new singleton format, without passing the IPBWI object into its constructor, and it's working just fine!
Edited by neen, 15 May 2011 - 09:47 PM.
#9
Posted 16 May 2011 - 12:41 AM
#10
Posted 04 November 2011 - 01:54 PM
Great work
Im using Yii Framework, and I've started to create Yii extension for Yii to make IPB session connected bridge.
#11
Posted 26 November 2011 - 01:34 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users













