PHPackages                             miniature/component - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. miniature/component

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

miniature/component
===================

A template for a component of PHP-classeswith the purpose of a component architecture. A black-box approach on dependency injection.

0.1.2(4y ago)05MITPHPPHP &gt;=7.4

Since May 25Pushed 4y ago1 watchersCompare

[ Source](https://github.com/guidoerfen/miniature-component)[ Packagist](https://packagist.org/packages/miniature/component)[ RSS](/packages/miniature-component/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (0)

[![](https://github.com/guidoerfen/miniature-component/raw/master/img/miniature-logo-100px.png)](https://github.com/guidoerfen/miniature-component/blob/master/img/miniature-logo-100px.png)

Component
=========

[](#component)

### Warning!

[](#warning)

This is still on an experimental level. We don't know if we've got everything together currently. Extensive testing needs to be done as well.

### Purpose

[](#purpose)

[ ![](https://github.com/guidoerfen/miniature-component/raw/master/img/component-diagram-300px.png)](https://github.com/guidoerfen/miniature-component/blob/master/DIAGRAM.md)This is a template for a \*\*component of PHP-classes\*\* provided by a \[\*\*dependency injection container\*\*\](#the-di-mapping) (DI-Container). The container itself is hidden by the \[\*\*component instance\*\*\](#the-instance-of-the-component) (\*\*black box approach\*\*) which from the outside serves as a \[facade\](#coupling-detection-and-protection). As a facade, the component is provided with a mechanism of access restriction. This access restriction in return ist the wiring of [**the component coupling**](#wiring-the-coupling)and the much-needed bottleneck regarding the communication of the classes residing in the container to the outer world. There is also a [**violation detection routine**](https://github.com/guidoerfen/miniature-component/blob/master/VIOLATION-DETECTING.md)ensuring the black box is kept closed.

The behaviour can be changed easily by the help of certain injections and overrides. The DI-Container is an independent package of its own.

### What does "Component" mean in this context?

[](#what-does-component-mean-in-this-context)

We are seeking for a toolset to build a composite component architecture. We are trying to build a tiny framework, that enables us to set up something like this relatively easily.

[![component architecture](img/TwoComponents.png)](img/TwoComponents.png)

If this does not look familiar to you and if the [Cohesion &amp; Coupling Problem](https://en.wikipedia.org/wiki/Coupling_(computer_programming))is not on your agenda it is likely that you are using a different terminology and that this package is absolutely not for you.

You might want to visit an [extended diagram](https://github.com/guidoerfen/miniature-component/blob/master/DIAGRAM.md)first in order to get a better idea.

### The basic steps of setting up a component:

[](#the-basic-steps-of-setting-up-a-component)

- Inheritance from the `Miniature\Component\Component` Singleton and giving that a **distinctive self speaking name**
- Setting up a **configuration folder** and injecting the directory path information to the Component
    - Providing configuration-files (PHP-array or YAML) ...
        - that contain the **dependency injection wiring** and
        - the **component coupling wiring**
- And you are ready to go

### One note before you continue:

[](#one-note-before-you-continue)

This package provides certain dependency wiring and black-/grey-/white-boxing mechanisms that might be useful for releasing component architectures. This is mainly about structure, access controll and dependency management. This doesn't mean that these are most sufficient for the task of component architecture as such. Other means might be way more sustainable. Consider bundling, separate deployment and versioning first.

Installation
============

[](#installation)

### Using Composer

[](#using-composer)

```
composer require miniature/component
```

### Downloading Package

[](#downloading-package)

You'll also need the [**DI-Container package**](https://github.com/guidoerfen/miniature-di_container).

Unzip both to a directory named **`Miniature`**. Add to your autoload something like the following:

```
