Giter Site home page Giter Site logo

di's People

Contributors

dongilbert avatar ekho avatar marcqualie avatar toopay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

di's Issues

How can i pass the container object to controller?

<?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

Container aware interface?

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?

Reuse instance?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.