00f100 / fcphp-provider
Provider Manager for FcPHP
Installs: 56
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Type:package
Requires
- php: >=7.2
- 00f100/fcphp-autoload: 0.*
- 00f100/fcphp-cache: 0.*
- 00f100/fcphp-di: 0.*
Requires (Dev)
- 00f100/phpdbug: *
- phpunit/phpunit: 6.*
README
Package do manage providers. This package use FcPhp Di to inject dependency.
How to install
Composer:
$ composer require 00f100/fcphp-provider
or composer.json
{ "require": { "00f100/fcphp-provider": "*" } }
How to use
Create class extends IProviderClient
to inject dependencies of your application
<?php namespace Some\Example { use FcPhp\Di\Interfaces\IDi; use FcPhp\Provider\Interfaces\IProviderClient; class ProviderClientExample implements IProviderClient { /** * Method to configure Di in providers * * @param FcPhp\Di\Interfaces\IDi $di Di Instance * @return void */ public function getProviders(IDi $di) :IDi { $di->set('Class', '\Class', [], ['SetConfiguration', => ['item1', 'item2', 'item3']]); $di->set('Class2', '\Class', ['instance' => $this->get('Class')]); return $di; } } }
Create new instance of IProvider to process providers
<?php use FcPhp\Di\Facades\DiFacade; use FcPhp\Provider\Facades\ProviderFacade; $PathCache = 'tests/var/cache'; $pathToAutoload = 'tests/*/*/config'; $provider = ProviderFacade::getInstance($pathToAutoload, $PathCache); $di = DiFacade::getInstance(); // Add new provider to process $provider->addProviders(['Some\Example\ProviderClientExample']); // Execute ... $provider->make(); // Now instance of di have configuration ... $di->make('Class2'); // Return new \Class(new \Class()) ....