{"id":18996063,"url":"https://github.com/00f100/fcphp-di","last_synced_at":"2025-07-15T09:04:11.204Z","repository":{"id":56893979,"uuid":"93574081","full_name":"00F100/fcphp-di","owner":"00F100","description":" Package to manage dependency injection","archived":false,"fork":false,"pushed_at":"2019-07-29T00:47:21.000Z","size":77,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-17T03:08:21.317Z","etag":null,"topics":["dependency","dependency-injection","fcphp","fcphp-di","injection","php7"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/00F100.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-07T00:11:33.000Z","updated_at":"2022-02-12T13:16:19.000Z","dependencies_parsed_at":"2022-08-20T16:10:41.864Z","dependency_job_id":null,"html_url":"https://github.com/00F100/fcphp-di","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/00F100%2Ffcphp-di","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/00F100%2Ffcphp-di/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/00F100%2Ffcphp-di/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/00F100%2Ffcphp-di/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/00F100","download_url":"https://codeload.github.com/00F100/fcphp-di/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250252239,"owners_count":21399959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency","dependency-injection","fcphp","fcphp-di","injection","php7"],"created_at":"2024-11-08T17:33:48.422Z","updated_at":"2025-04-22T13:49:16.367Z","avatar_url":"https://github.com/00F100.png","language":"PHP","readme":"# FcPhp Dependency Injection\n\nPackage to manage dependencies of project.\n\n[![Build Status](https://travis-ci.org/00F100/fcphp-di.svg?branch=master)](https://travis-ci.org/00F100/fcphp-di) [![codecov](https://codecov.io/gh/00F100/fcphp-di/branch/master/graph/badge.svg)](https://codecov.io/gh/00F100/fcphp-di) [![Total Downloads](https://poser.pugx.org/00F100/fcphp-di/downloads)](https://packagist.org/packages/00F100/fcphp-di)\n\n## How to install\n\nComposer:\n```sh\n$ composer require 00f100/fcphp-di\n```\n\nor add in composer.json\n```json\n{\n    \"require\": {\n        \"00f100/fcphp-di\": \"*\"\n    }\n}\n```\n\n## How to use\n\n```php\n\u003c?php\n\nuse FcPHP\\Di\\Facades\\DiFacade;\n\n$di = DiFacade::getInstance();\n\n/**\n * Method to set new class\n *\n * @param string $id Identify of instance\n * @param string $namespace Namespace of class\n * @param array $args Args to construct class\n * @return void\n */\n$di-\u003eset(string $id, string $namespace, array $args = [], array $setters = [], bool $singleton = true);\n\n/**\n * Method to overwrite instance before make\n *\n * @param string $id Identify instance\n * @param string $namespace Namespace of class\n * @param array $args Args to construct class\n * @param array $setters Setters to class\n * @return FcPhp\\Di\\Interfaces\\IDi\n */\n$di-\u003eoverwrite(string $id, string $namespace, array $args = [], array $setters = []) ;\n\n/**\n * Method to get instance of Container\n *\n * @param string $id Identify of instance\n * @param array $args Args to construct instance\n * @return FcPhp\\Di\\Interfaces\\IContainer\n */\n$di-\u003eget(string $id, array $args = [], array $setters = []);\n\n/**\n * Method to configure setters to class\n *\n * @param string $id Identify instance\n * @param array $setters Setters to class\n * @return FcPhp\\Di\\Interfaces\\IDi\n */\n$di-\u003esetter(string $id, array $setters);\n\n/**\n * Method instance of class\n *\n * @param string $id Identify of instance\n * @param array $args Args to construct instance\n * @return mixed\n */\n$di-\u003emake(string $id, array $args = [], array $setters = []);\n```\n\n## Examples\n\n```php\n\u003c?php\n\nuse FcPHP\\Di\\Facades\\DiFacade;\n\n$di = DiFacade::getInstance();\n\n/*\nnamespace Namespace\\To {\n    class Example {\n        public $foo;\n        private $anotherFoo;\n        public function __construct(string $foo) {\n            $this-\u003efoo = $foo;\n        }\n        public function setAnotherFoo($foo) {\n            $this-\u003eanotherFoo = $foo;\n        }\n        public functio getAnotherFoo() {\n            return $this-\u003eanotherFoo;\n        }\n    }\n    class ExampleBar {\n        public $example;\n        __construct(Example $example) {\n            $this-\u003eexample = $example;\n        }\n    }\n}\n*/\n$di-\u003eset('Example', 'Namespace\\To\\Example', ['foo' =\u003e 'bar'], ['setAnotherFoo', 'AnotherBar']);\n$di-\u003eset('ExampleBar', 'Namespace\\To\\ExampleBar', ['example' =\u003e $di-\u003eget('Example')]);\n\n// Print \"bar\"\necho $di-\u003emake('ExampleBar')-\u003eexample-\u003efoo\n\n// Print \"AnotherBar\"\necho $di-\u003emake('ExampleBar')-\u003eexample-\u003egetAnotherFoo();\n```\n\n## Events\n\n```php\n\u003c?php\n\nuse FcPHP\\Di\\Facades\\DiFacade;\nuse FcPhp\\Di\\Interfaces\\IInstance;\nuse FcPhp\\Di\\Interfaces\\IContainer;\n\n$di = DiFacade::getInstance();\n\n$di-\u003eevent([\n    'beforeSet' =\u003e function(string $id, string $namespace, array $args, array $setters, bool $singleton) {\n\n    },\n    'afterSet' =\u003e function(string $id, string $namespace, array $args, array $setters, bool $singleton, IInstance $instance) {\n\n    },\n    'beforeGet' =\u003e function(string $id, array $args, array $setters) {\n\n    },\n    'afterGet' =\u003e function(string $id, array $args, array $setters, IInstance $instance, IContainer $container) {\n\n    },\n    'beforeMake' =\u003e function(string $id, array $args, array $setters) {\n\n    },\n    'afterMake' =\u003e function(string $id, array $args, array $setters, IInstance $instance, IContainer $container, $class) {\n\n    }\n]);\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F00f100%2Ffcphp-di","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F00f100%2Ffcphp-di","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F00f100%2Ffcphp-di/lists"}