Download the PHP package comphp/service-management without Composer

On this page you can find all versions of the php package comphp/service-management. 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 service-management

CommonPHP - Service Manager

CommonPHP's Service Manager is a comprehensive solution for managing and injecting services throughout your PHP application. It provides an elegant and powerful API that allows you to manage service life-cycles, register and retrieve services, and work with service providers, amongst other capabilities.

Features

ServiceManager vs ServiceContainer

To keep the management and utilization of services logically separated and maintain a clean architecture, we've divided these responsibilities into two main classes: ServiceManager and ServiceContainer.

The ServiceManager is responsible for the registration, instantiation, and general management of services. It serves as the hub where services are defined, dependencies are resolved, and lifetimes are managed. It is meant to be utilized during the bootstrapping or startup phase of your application.

Conversely, the ServiceContainer is designed to be a consumer of these services during the application's execution. It provides a simplified, read-only interface for accessing services managed by the ServiceManager. This approach allows for an explicit and clear distinction between service configuration and consumption, fostering cleaner, more maintainable code.

Requirements

The CommonPHP framework requires PHP 8.1 or newer. This library specifically has the following dependencies:

Installation

You can install CommonPHP\ServiceManagement using Composer:

Basic Usage

The primary class of the Service Manager is CommonPHP\ServiceManager\ServiceManager. Start by creating a new instance of ServiceManager:

The ServiceManager instance provides several methods for managing and retrieving services.

Registering Services

You can register services using the register method:

This registers the service by its class name. You can then retrieve instances of the service using the get method (see below).

Retrieving Services

Use the get method to retrieve services:

This retrieves a new instance of the registered service.

Registering Aliases

The aliases property of the ServiceManager is an instance of AliasRegistry which lets you register service aliases:

In this example, the MyInterface is aliased to the MyClass. Therefore, when a service requests MyInterface, an instance of MyClass is returned.

Registering Namespaces

The namespaces property of the ServiceManager is an instance of NamespaceRegistry which lets you register entire namespaces:

All classes in the registered namespace are treated as services.

Registering Service Providers

The providers property of the ServiceManager is an instance of ProviderRegistry which lets you register service providers:

Service providers are classes that implement the ServiceProviderContract and are responsible for providing instances of services.

Bootstrapping Services

Services that require certain actions upon instantiation that cannot be handled by the constructor alone can implement the BootstrapperContract. When such a service is instantiated by the ServiceManager, its bootstrap method is automatically called:

Bootstrapping Service Providers

Similarly, service providers that need to perform certain actions upon instantiation can also implement the BootstrapperContract. Their bootstrap method will be automatically called when they are instantiated:

In both examples, the bootstrap method is intended to be invoked internally by the ServiceManager and should not be manually called to prevent unexpected behavior.

Documentation

Please see the examples directory for more detailed examples on how to use each of the features provided by the Service Manager.

API Reference

API Reference

This is a high-level overview of the API. For detailed information about classes, methods, and properties, please refer to the source code and accompanying PHPDoc comments.

Examples

Here are some examples of using CommonPHP\ServiceManager. You can find the full source code for these examples in the examples directory of this repository.

Contributing

Contributions are always welcome! Please read the contribution guidelines first.

Testing

This project uses PHPUnit for unit testing. Follow the instructions below to run the tests:

  1. Ensure you have PHPUnit installed. If not, you can install it with Composer:

  2. Navigate to the project's root directory.

  3. Run the tests using the following command:

  4. If the tests are successful, you will see output similar to:

We recommend regularly running these tests during development to help catch any potential issues early. We also strive for a high level of test coverage, and additions to the codebase should ideally include corresponding tests.

For more detailed output or for integration into continuous integration (CI) systems, PHPUnit can generate a log file in a variety of formats. Check the PHPUnit documentation for more information.

License

This project is licensed under the MIT License. See the LICENSE.md file for details.


All versions of service-management with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
psr/container Version ^2.0
comphp/di Version ^v0.2
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 comphp/service-management contains the following files

Loading the files please wait ....