thephpleague / di Goto Github PK
View Code? Open in Web Editor NEWAn Ultra-Fast Dependency Injection Container. DEPRECATED
Home Page: https://github.com/orno/di
License: MIT License
An Ultra-Fast Dependency Injection Container. DEPRECATED
Home Page: https://github.com/orno/di
License: MIT License
<?php namespace App\Core;
use League\Container\Container;
class AppController
{
private $container;
public function __construct( Container $container ) {
$this->container = $container;
}
public function __get( $name ) {
if ( $this->container->get( $name ) ) {
return $this->container->get( $name );
}
}
}
Apparently i got:
Argument 1 passed to League\Container\Container::__construct() must implement interface League\Container\ServiceProvider\ServiceProviderAggregateInterface, string given
Btw, Im using Auto Wiring
I'm just wondering if it's worth adding a ContainerAwareInterface (methods getContainer
and setContainer
)? I'm just trying to imagine how to correctly pass the container around without using a singleton.
So, for example, an Application class might create a container and bind a database connection and let's say a user type object. The application could create a controller to execute the application, but before it does, it could invoke
$controller->setContainer($this->container);
or similar. Or, it could do this:
if ($controller instanceof ContainerAwareInterface)
{
$controller->setContainer($this->container);
}
$controller->execute();
Thoughts?
Each time we get an object, di returns a new instance of it.
How about adding a way to get the same instance to be returned for all calls?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.