Download the PHP package loophp/service-alias-autoregister-bundle without Composer

On this page you can find all versions of the php package loophp/service-alias-autoregister-bundle. 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-alias-autoregister-bundle

![Latest Stable Version][latest stable version] ![GitHub stars][github stars] ![Total Downloads][total downloads] ![License][license] ![Donate!][donate github]

Service Alias Auto Register

A bundle for Symfony.

Description

The S.O.L.I.D. principles are a quintet of design guidelines aimed at enhancing the clarity, flexibility, and maintainability of software designs. Among these is the Open-Closed Principle, which advocates for the use of interfaces over concrete implementations.

In Symfony, the usual practice is to depend on concrete service implementations when injecting services, as opposed to utilizing an interface. Unfortunately, this approach compromises our code's flexibility and occasionally complicates testing.

Fortunately, this limitation can be overcome in Symfony by [manually introducing aliases][50] in the container for each class, a method that enhances flexibility and testing capabilities.

To rectify this issue and augment this practice, this bundle will declare new aliases in the Symfony container. Consequently, when a discovered service implements interfaces, aliases are automatically generated. For example, if a service implements three interfaces, the container will automatically create three new corresponding aliases.

These aliases are automatically created using the Fully Qualified Domain Name (FQDN) of the service's class when the discovered services implement one or several interfaces.

Leveraging aliases allows the injection of services using interfaces and named parameters instead of specific implementations, thereby addressing the often neglected Open-Closed Principle. In this way, our code becomes more adherent to S.O.L.I.D. principles, specifically the Open-Closed Principle, and hence more robust and easier to manage.

The following examples are showing an existing situation, as you can see, we do not respect that principle and we inject an concrete implementation directly:

When the bundle is enabled, you can inject the repository using an interface, using a specific parameter name.

We can even do better by injecting it in the constructor. Then we can use the interface when injecting, and we can use the implementation in the property. Best of both world.

Installation

See the next section to learn how to enable it in your project.

Usage

The bundle can be enabled by just adding a specific tag: autoregister.alias

Adds all the aliases it can find

Adds only specific services implementing specific interfaces only

Once it is done, do the following command to verify:

Another example: find all the new aliases for Doctrine repositories:

Configure the bundle

You can configure this bundle by creating a configuration file in your application.

The configuration keys that are available:

Contributing

Feel free to contribute by sending Github pull requests.

If you can't contribute to the code, you can also sponsor me on Github.

Changelog

See [CHANGELOG.md][47] for a changelog based on git commits.

For more detailed changelogs, please check the release changelogs.

[latest stable version]: https://img.shields.io/packagist/v/loophp/service-alias-autoregister-bundle.svg?style=flat-square [github stars]: https://img.shields.io/github/stars/loophp/service-alias-autoregister-bundle.svg?style=flat-square [total downloads]: https://img.shields.io/packagist/dt/loophp/service-alias-autoregister-bundle.svg?style=flat-square [license]: https://img.shields.io/packagist/l/loophp/service-alias-autoregister-bundle.svg?style=flat-square [donate github]: https://img.shields.io/badge/Sponsor-Github-brightgreen.svg?style=flat-square

[44]: https://tomasvotruba.com/blog/2017/10/16/how-to-use-repository-with-doctrine-as-service-in-symfony/

[47]: https://github.com/loophp/service-alias-autoregister-bundle/blob/master/CHANGELOG.md

[50]: https://symfony.com/doc/current/service_container.html#binding-arguments-by-name-or-type


All versions of service-alias-autoregister-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >= 8.1
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 loophp/service-alias-autoregister-bundle contains the following files

Loading the files please wait ....