Download the PHP package inanepain/servicemanager without Composer

On this page you can find all versions of the php package inanepain/servicemanager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package servicemanager

= inanepain/servicemanager image:./icon.png[title=inanepain/stdlib,25] // tag::tagConfig[] :author: Philip Michael Raab :email: [email protected] :description: Factory-driven dependency injection container. :keywords: inanepain, library, servicemanager, container, psr-11 :copyright: Unlicense :homepage: https://github.com/inanepain/servicemanager :revnumber: 0.2.0 :revdate: 2026-02-23 :experimental: :hide-uri-scheme: :icons: font :source-highlighter: highlight.js :toc: left :sectanchors: :idprefix: topic- :idseparator: - :pkg-vendor: inanepain :pkg-name: servicemanager :pkg-id: {pkg-vendor}/{pkg-name} // end::tagConfig[]

== image:./icon.png[title={pkg-id},25] {pkg-id}

{description}

:sectnums:

<<<

:leveloffset: +1

= Install

.composer [source,shell,subs=attributes+]

composer require {pkg-id}

:leveloffset!:

<<<

:leveloffset: +1

= Overview

inanepain/servicemanager is a small, factory-driven dependency injection container.

At its core, a ServiceManager is a registry of services identified by a string name. Each service is produced by a factory (a callable).

The factory signature is intentionally simple:

[source,php]

function (\Inane\ServiceManager\ServiceManager $sm): mixed

Passing the ServiceManager to factories enables dependency resolution inside the factory (e.g. $sm->get('config')).

== Lifecycle: get() vs build()

The ServiceManager supports two retrieval modes:

This makes it easy to mix singleton-style services (via get()) with transient services (via build()).

== Errors

If a service name is not registered, get() and build() throw Inane\ServiceManager\Exception\NotFoundException (implements Psr\Container\NotFoundExceptionInterface) with the message Service '{name}' not found..

== API Summary

:leveloffset!:

<<<

:leveloffset: +1

= Usage

== Quickstart

Register a service with register() and fetch it with get():

[source,php]

<?php

declare(strict_types=1);

require_once 'vendor/autoload.php';

use Inane\ServiceManager\ServiceManager;

$sm = new ServiceManager();

$sm->register('now', static fn (ServiceManager $sm) => new DateTimeImmutable('now'));

$a = $sm->get('now'); $b = $sm->get('now');

// get() caches, so $a and $b are the same instance. var_dump($a === $b);

== Transient services with build()

Use build() when you want a new instance each time:

[source,php]

<?php

declare(strict_types=1);

require_once 'vendor/autoload.php';

use Inane\ServiceManager\ServiceManager;

$sm = new ServiceManager();

$sm->register('uuid', static fn (ServiceManager $sm) => bin2hex(random_bytes(16)));

$a = $sm->build('uuid'); $b = $sm->build('uuid');

// build() always invokes the factory. var_dump($a !== $b);

== Factories can resolve dependencies

Factories receive the ServiceManager instance, so they can depend on other services:

[source,php]

<?php

declare(strict_types=1);

require_once 'vendor/autoload.php';

use Inane\ServiceManager\ServiceManager; use Psr\Log\NullLogger;

$sm = new ServiceManager();

$sm->register('logger', static fn (ServiceManager $sm) => new NullLogger());

$sm->register('worker', static function (ServiceManager $sm) { $logger = $sm->get('logger');

return new class($logger) {
    public function __construct(private object $logger) {}
};

});

$worker = $sm->get('worker');

== Bulk registration with createServiceManager()

If you already have a mapping of service names to factories, you can create and populate a manager in one step.

[source,php]

<?php

declare(strict_types=1);

require_once 'vendor/autoload.php';

use Inane\ServiceManager\ServiceManager; use Inane\Stdlib\Options;

$services = new Options([ 'config' => static fn (ServiceManager $sm) => new Options(['env' => 'dev']), 'answer' => static fn (ServiceManager $sm) => 42, ]);

$sm = ServiceManager::createServiceManager($services);

var_dump($sm->get('answer'));

== Missing services

If you call get() or build() with an unregistered name, an Inane\ServiceManager\Exception\NotFoundException (PSR-11 Psr\Container\NotFoundExceptionInterface) is thrown.

:leveloffset!:


All versions of servicemanager with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
psr/container Version ^2.0
inanepain/config Version >=0.4.0
inanepain/stdlib Version >=0.8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package inanepain/servicemanager contains the following files

Loading the files please wait ...