Skip to content

Simple Dependencies Container following PSR-11 standards

License

Notifications You must be signed in to change notification settings

InitPHP/Container

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

InitPHP Dependencies Container

Simple Dependencies Container following PSR-11 standards.

Note : This is a pre-release version of the library currently available. Report potential bugs and feature requests to the issue section of this repo.

Requirements

Installation

composer require initphp/container:dev-main

Usage

Check the Example directory for an example usage.

require_once "vendor/autoload.php";
use InitPHP\Container\Container;

class UserModel
{
    private string $name;

    public function set(string $name)
    {
        $this->name = $name;
    }
    
    public function get()
    {
        return $this->name ?? null;
    }
}

class User
{
    private $model;

    public function __construct(UserModel $model)
    {
        $this->model = $model;
    }

    public function getModel()
    {
        return $this->model;
    }
}

$container = new Container();
$user = $container->get(\Example\User::class);
$model = $user->getModel();
$model->set('Muhammet');
echo $user->getModel()->get();

Contributing

All contributions to this project will be published under the MIT License. By submitting a pull request or filing a bug, issue, or feature request, you are agreeing to comply with this waiver of copyright interest.

  1. Fork it ( https://github.com/initphp/container/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am "Add some feature")
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Credits

License

Copyright © 2022 MIT License