Download the PHP package migears/wiring without Composer

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

migears/wiring

Version

Config-driven container wiring: load a PHP array of factories and register it into a PSR-11 container.

Background: miGears is the open-source successor of TinyGears, a self-developed PHP framework. It was renamed and open-sourced recently because the name TinyGears is already taken in the open-source community.

Contents

Why

The composition root is the one place that knows every concrete class, and writing it by hand is repetitive — the same set($id, $factory) line, once per entry. This package moves that repetition into a plain PHP array, so the wiring reads as a table of id => factory:

Installation

Requires PHP 8.1+. The only dependency is psr/container.

Quick Start

Write the wiring as data — config/wiring-list.php, beside src/ and tests/:

Register it once, at bootstrap:

$container is any PSR-11 container that also exposes set(); the loader checks for it at load time. A hand-written one is under thirty lines:

API Reference

MiGears\Wiring\Wiring

Loads $file and registers every entry into $container. The container is typed as the standard Psr\Container\ContainerInterface; because PSR-11 has no registration side, load() also requires a set(string $id, callable $factory) method and checks for it up front. The file must return array<string, callable>:

The file is read and validated in full first; only then is anything registered. Factories are registered lazily, so they run on the container's first get() for that id, and the container's result is cached as usual. The loader stays independent of any particular container: it only needs PSR-11 plus set().

MiGears\Wiring\WiringException

Thrown by load() when the file is missing or unreadable, does not return an array, holds an entry whose id is not a non-empty string or whose factory is not callable, or the container exposes no set(). It extends RuntimeException.

Errors

Every failure is an assembly mistake, so it fails loudly at initialization instead of surfacing later as a missing entry inside a request:

Condition Message
file missing or unreadable Wiring config not found or not readable: <file>
file did not return an array Wiring config must return an array, got <type>: <file>
id is not a non-empty string Wiring entry ids must be non-empty strings, got <type>: <file>
factory is not callable Wiring entry '<id>' must be a callable, got <type>: <file>
container has no set() Wiring target must be a writable PSR-11 container (no set() method), got <type>

Testing

License

MIT. See LICENSE.


migears/wiring

Version

配置驱动的容器装配:读取一份 PHP 工厂数组,登记进一个 PSR-11 容器。

背景:miGears 是自研 PHP 框架 TinyGears 的开源后继。更名并开源,是因为 TinyGears 这个名字在开源社区已被占用。

目录

为什么

组合根是唯一知道每个具体类的地方,而手写它很重复——同样的 set($id, $factory),一个条目一行。 本包把这份重复挪进一份普通 PHP 数组,于是装配读起来就是一张 id => factory 表:

安装

需要 PHP 8.1+。唯一依赖是 psr/container。

快速开始

把装配写成数据——config/wiring-list.php,与 src/、tests/ 同级:

在启动时登记一次:

$container 是任何还暴露了 set() 的 PSR-11 容器;加载器会在加载时检查它是否存在。自己写一个不到三十行:

API 参考

MiGears\Wiring\Wiring

加载 $file,把每个条目登记进 $container。容器按标准的 Psr\Container\ContainerInterface 声明; 由于 PSR-11 没有登记面,load() 还要求一个 set(string $id, callable $factory) 方法,并在开头检查它 是否存在。文件必须返回 array<string, callable>:

文件先被完整读取并校验,之后才开始登记。工厂是懒登记的,因此它们在该 id 首次 get() 时才运行, 容器的结果照常被缓存。加载器不依赖任何特定容器:它只需要 PSR-11 加上 set()。

MiGears\Wiring\WiringException

当文件缺失或不可读、未返回数组、含有 id 不是非空字符串或工厂不是 callable 的条目,或容器没有暴露 set() 时,由 load() 抛出。它继承 RuntimeException。

错误

每个失败都是装配错误,因此在初始化时大声失败,而不是稍后在请求里表现为「条目不见了」:

情形 消息
文件缺失或不可读 Wiring config not found or not readable: <file>
文件没有 return 数组 Wiring config must return an array, got <type>: <file>
id 不是非空字符串 Wiring entry ids must be non-empty strings, got <type>: <file>
工厂不是 callable Wiring entry '<id>' must be a callable, got <type>: <file>
容器没有 set() Wiring target must be a writable PSR-11 container (no set() method), got <type>

测试

许可证

MIT,见 LICENSE。


All versions of wiring with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
psr/container Version ^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 migears/wiring contains the following files

Loading the files please wait ...