alireza-h/service-container

There is no license information available for the latest version (dev-master) of this package.

PHP service container

dev-master 2020-01-18 13:09 UTC

This package is auto-updated.

Last update: 2024-11-19 00:04:12 UTC


README

PHP service container

Installation

$ composer require alireza-h/service-container

Register service

ServiceContainer::getInstance()
            ->register(AuthService::class)
            ->register(RouteCollection::class)
            ->register(RequestContext::class)
            ->register(UrlService::class, null, [RouteCollection::class, RequestContext::class]);

Access to registered service

ServiceContainer::getInstance()
            ->service(AuthService::class);
            
ServiceContainer::getInstance()
            ->service(UrlService::class);