Download the PHP package paket/bero without Composer

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

Bero

Bero (Swedish depend) is a dependency injection container for PHP. By inspecting class constructors Bero can instantiate classes and all their class dependencies with any depth. It could be described as a on-the-fly factory creator.

Usage

Installation

composer require paket/bero

Requirements

Requires PHP 7.2 or higher.

General

Bero inspect method or function parameters for callables or class constructors to be able to instantiate those parameters. To be able to instantiate a parameter it has to have class type, if a type is an interface Bero has to be configured beforehand for what implementation to pick. Every class must either already be loaded or be able to be loaded by autoloader.

This means that if a class with constructor parameter that is either missing or of scalar type, Bero can't instantiate it. Bero has a configuration API for those use cases.

When the same class is used multiple times through the dependency chain Bero reuses the same object instance for that class for the entire lifetime of Bero (ideally the length of a request). This is what you probably want in the vast majority of cases, e.g. only one class instance per request for a database repository.

This also means that any state stored within an instance will be shared with all usages of that class during the lifetime of Bero, for PHP that works pretty well because of PHP's share nothing between request, i.e. shared state will only be for that request, meaning you can use Bero for a singleton pattern per request basis, e.g. keeping track of the current logged in user for this request.

If it is needed to create a new instance for each usage it is recommended to create a factory class instead, depend on the factory class and then ask the factory class for each usage.

Implementations

Bero has multiple implementations for usage in different scenarios

Instantiation

MinimalBero

StrictBero

Dependency injection

Assume these classes

Construct class instances & retrieve them

Instantiate class B that has A as a dependency

Or a callable can be used to retrieve multiple class instances and optionally return a result.

Use existing class instance together with Bero

Assume our application already has a class instance of A that we want to use together with Bero.

Custom factory for creating class instance

You can also provide your own callable to be called when Bero needs to instantiate a class.

Note that the supplied callable can also depend on class dependencies to be used to instantiate your class.

Callable will only be called when needed & only once & then Bero will cache the result.

addCallable() is good way to handle non-instantiable classes.

Map interface to implementation

If your class depends on an interface you need to tell Bero which implementation to be used.

Make Bero self aware

Normally you would only call Bero once when bootstrapping the application, e.g. instantiate the controller & all it's dependencies & then execute it.

However sometimes your application makes a fork in it's execution path that is dependent on some calculated value that is unknown at bootstrap & because you only want to instantiate the execution path that is needed & not all of them you can depend on Bero further down in your application.

Assume following

By adding Bero to itself we can ask for the Bero instance further down in the application & retain all previously constructed class instances & access them, thus class instance field $a for FooService will be the same as the global class instance $a & not a newly created instance.

License

Bero is released under the MIT License. See the bundled file LICENSE.txt.


All versions of bero with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
psr/container Version ^1.0 || ^2.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 paket/bero contains the following files

Loading the files please wait ....