SitePoint Sponsor |
|
User Tag List
Results 26 to 42 of 42
-
May 11, 2006, 21:34 #26
Originally Posted by lastcraft
-
May 12, 2006, 04:20 #27
- Join Date
- Jun 2004
- Location
- London, UK
- Posts
- 227
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Still waiting to see a stable release of a 'finished' PHP DI container really. There's real interest here in using it, but none at all in reinventing the wheel by developing our own one.
Forgive my ignorance if I've missed one, I've been in a meeting for several months. But last time I checked Pico came complete with broken tests, so I chose to hold off...
-
May 12, 2006, 05:10 #28
Phemto v2 sounds interesting, especially if can keep it to ~100 lines. The implemtation I have atm comes in at around ~180.
-
May 13, 2006, 07:00 #29
- Join Date
- Apr 2003
- Location
- London
- Posts
- 2,423
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Hi...
Originally Posted by Ren
. It's 150 at the moment, so it may end up at 250.
yours, Marcus
p.s. CVS is up, but you now have to check everything out again. Looks like I'm in for an afternoon of file copying...
Marcus Baker
Testing: SimpleTest, Cgreen, Fakemail
Other: Phemto dependency injector
Books: PHP in Action, 97 things
-
May 14, 2006, 22:34 #30
Originally Posted by lastcraft
-
May 21, 2006, 04:25 #31
Originally Posted by 33degrees
-
May 21, 2006, 04:51 #32
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Until it's moved, you can get it from http://lamplib.cvs.sourceforge.net/lamplib/phemto/
-
May 21, 2006, 14:38 #33
- Join Date
- Apr 2003
- Location
- London
- Posts
- 2,423
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Hi...
Originally Posted by Ren
yours, MarcusMarcus Baker
Testing: SimpleTest, Cgreen, Fakemail
Other: Phemto dependency injector
Books: PHP in Action, 97 things
-
May 30, 2006, 12:35 #34
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sorry for taking so long...
> the factories could be locators as well, so it doesn't feel accurate.
Nope, the idea doesn't feel right to me either, some how though I can't put the explanation into words (yet)
> Was the ugly-part a joke, or do you really find the solution unsatisfactory?
Yer, the script I posted is ugly as it stands and I have since done a better implementation of it; I knew that I could... I just hadn't found the time back then, so now I'm a lot happier with the result.
PHP Code:include_once( 'configs/configs.php' );
// ...
// declare dependencies
Component::set( 'logger' );
Component::set( 'configs' );
Component::set( 'request' );
// note, i need to wrap the array with an instance of typeof IDataspace...
Component::get( 'iconfiguration' ) -> import( new Parameters( $configs ) );
PHP Code:// later...
$db = Component::get( 'iconfiguration' ) -> get( 'db' ); // database configuration
Last edited by Dr Livingston; Jun 3, 2006 at 03:01.
-
Jun 29, 2006, 15:06 #35
- Join Date
- Apr 2003
- Location
- London
- Posts
- 2,423
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Hi...
There is now some code in CVS for phemto. It's currently 173 lines of code. This is still very much alpha code and the design and features may change radically. Anyway, comments would be appreciated...
http://sourceforge.net/projects/phemto/
It's a CVS pserver checkout currently. I'll get a tarball up in a couple of days.
yours, MarcusMarcus Baker
Testing: SimpleTest, Cgreen, Fakemail
Other: Phemto dependency injector
Books: PHP in Action, 97 things
-
Jun 29, 2006, 15:48 #36
- Join Date
- May 2005
- Location
- Finland
- Posts
- 608
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Dr Livingston
I'm at a stage in my framework where I'm seeing my code infested with ugly, ugly, repetitive wiring that really doesn't belong. I'm using a standard, non-static service locator right now, but it isn't doing me much in that respect. I'd be very interested in seeing whatever solutions you've come up with for yourselves.
lastcraft: Will definitely take a look as soon as I have time.
-
Jun 29, 2006, 16:11 #37
Originally Posted by lastcraft
Definately think DI should be at the heat of a workflow type system, just haven't explored it further.
Oh, and if want to shave a few lines...
PHP Code:private function discoverInterfaces($class) {
$interfaces = array_merge(class_implements($class), class_parents($class));
$interfaces[] = $class;
return $interfaces;
}
-
Jun 29, 2006, 17:47 #38
- Join Date
- Jun 2003
- Location
- Iowa, USA
- Posts
- 3,749
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How have people tackled the problem of LazyLoading with DI? With pico, I had to make a handle class which was aware of the container, which I think is a bad code smell. Has anyone else put more thought into this than me?
PHP Code:class PicoLazyProxy {
protected $pico;
protected $class;
protected $path;
protected $subject;
public function __construct($pico, $class, $path='') {
$this->pico = $pico;
$this->class = $class;
$this->path = $path;
}
protected function subject() {
if (!($this->subject instanceof View)) {
if (!class_exists($this->class)) {
require_once $this->path.$this->class.'.php';
}
$this->subject = $this->pico->getComponentInstance($this->class);
}
return $this->subject;
}
public function __call($method, $args) {
return call_user_func_array(array($this->subject(), $method), $args);
}
}
Jason Sweat ZCE - jsweat_php@yahoo.com
Book: PHP Patterns
Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
Detestable (adjective): software that isn't testable.
-
Jun 29, 2006, 17:53 #39
- Join Date
- Apr 2003
- Location
- London
- Posts
- 2,423
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Hi...
Originally Posted by Ren
PHP Code:private function discoverInterfaces($class) {
if (! class_exists($class)) {
throw new Exception("Cannot inject missing class $class");
}
return array_merge(
array($class),
class_implements($class),
class_parents($class));
}
.
yours, MarcusMarcus Baker
Testing: SimpleTest, Cgreen, Fakemail
Other: Phemto dependency injector
Books: PHP in Action, 97 things
-
Jun 29, 2006, 18:00 #40
- Join Date
- Apr 2003
- Location
- London
- Posts
- 2,423
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Hi...
Originally Posted by sweatje
I don't think lazy code loading works with these automated schemes. It may be that the efficiency comes from caching the interfaces after the first run.
How are you finding Pico?
yours, MarcusMarcus Baker
Testing: SimpleTest, Cgreen, Fakemail
Other: Phemto dependency injector
Books: PHP in Action, 97 things
-
Jun 29, 2006, 18:37 #41
Originally Posted by sweatje
PHP Code:class LazyLoadingLocator extends ComponentLocatorDecorator
{
private $loaded = false;
private $fileName;
function __construct(ComponentLocator $locator, $fileName)
{
parent::__construct($locator);
$this->fileName = $fileName;
}
function getInstance(DependancyInjector $injector)
{
if (!$this->loaded)
$this->loaded = class_exists($this->getImplementation()) || require($this->fileName);
return parent::getInstance($injector);
}
}
-
Jun 30, 2006, 06:22 #42
- Join Date
- Jun 2003
- Location
- Iowa, USA
- Posts
- 3,749
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by lastcraft
Jason Sweat ZCE - jsweat_php@yahoo.com
Book: PHP Patterns
Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
Detestable (adjective): software that isn't testable.
Bookmarks