https://github.com/eliashaeussler/typo3-config-objects
🧱 Provides value objects for strictly typed TYPO3 configuration
https://github.com/eliashaeussler/typo3-config-objects
config typo3 value-object
Last synced: 10 months ago
JSON representation
🧱 Provides value objects for strictly typed TYPO3 configuration
- Host: GitHub
- URL: https://github.com/eliashaeussler/typo3-config-objects
- Owner: eliashaeussler
- License: gpl-2.0
- Created: 2025-04-16T07:03:37.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-04-24T05:56:37.000Z (10 months ago)
- Last Synced: 2025-05-01T12:05:52.687Z (10 months ago)
- Topics: config, typo3, value-object
- Language: PHP
- Homepage:
- Size: 84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Value objects for strictly typed TYPO3 configuration
[](https://coveralls.io/github/eliashaeussler/typo3-config-objects)
[](https://qlty.sh/gh/eliashaeussler/projects/typo3-config-objects)
[](https://github.com/eliashaeussler/typo3-config-objects/actions/workflows/cgl.yaml)
[](https://github.com/eliashaeussler/typo3-config-objects/actions/workflows/tests.yaml)
[](https://packagist.org/packages/eliashaeussler/typo3-config-objects)
This library provides custom value objects for strictly typed [TYPO3](https://typo3.org/) configuration.
They can be used to replace the usage of arrays in configuration files, such as `Confguration/Icons.php`.
## 🔥 Installation
[](https://packagist.org/packages/eliashaeussler/typo3-config-objects)
[](https://packagist.org/packages/eliashaeussler/typo3-config-objects)
```bash
composer require eliashaeussler/typo3-config-objects
```
## ⚡ Usage
It's pretty easy: Replace arrays in your configuration files with value objects 💅.
The following configuration classes are available:
* [`IconConfiguration`](#iconconfiguration-for-configurationiconsphp)
* [`MiddlewareConfiguration`](#middlewareconfiguration-for-configurationrequestmiddlewaresphp)
### [`IconConfiguration`](src/Configuration/IconConfiguration.php) (for `Configuration/Icons.php`)
**Before:**
```php
// Configuration/Icons.php
use TYPO3\CMS\Core;
return [
'tx-example-my-icon' => [
'provider' => Core\Imaging\IconProvider\SvgIconProvider::class,
'source' => 'EXT:example/Resources/Public/Icons/my-icon.svg',
],
'tx-example-my-second-icon' => [
'provider' => Core\Imaging\IconProvider\BitmapIconProvider::class,
'source' => 'EXT:example/Resources/Public/Icons/my-second-icon.jpg',
],
'tx-example-my-legacy-icon' => [
'provider' => Core\Imaging\IconProvider\SvgIconProvider::class,
'source' => 'EXT:example/Resources/Public/Icons/my-legacy-icon.svg',
'deprecated' => [
'since' => 'TYPO3 v12',
'until' => 'TYPO3 v13',
'replacement' => 'tx-example-my-new-icon',
],
],
'tx-example-my-new-icon' => [
'provider' => \Vendor\Example\Imaging\MyCustomIconProvider::class,
'renderer' => \Vendor\Example\Renderer\MyCustomIconRenderer::class,
],
];
```
**After:**
```php
// Configuration/Icons.php
use EliasHaeussler\Typo3ConfigObjects;
return Typo3ConfigObjects\Configuration\IconConfiguration::create()
// Add a list of icons to configure
->add(
Typo3ConfigObjects\ValueObject\Icon::create('tx-example-my-icon')
->useSvgIconProvider('EXT:example/Resources/Public/Icons/my-icon.svg'),
Typo3ConfigObjects\ValueObject\Icon::create('tx-example-my-second-icon')
->useBitmapIconProvider('EXT:example/Resources/Public/Icons/my-second-icon.jpg')
)
// You can also use deprecated icons
->add(
Typo3ConfigObjects\ValueObject\Icon::create('tx-example-my-legacy-icon')
->useSvgIconProvider('EXT:example/Resources/Public/Icons/my-legacy-icon.svg')
->setDeprecated(
new Typo3ConfigObjects\ValueObject\DeprecatedIcon(
since: 'TYPO3 v12',
until: 'TYPO3 v13',
replacement: 'tx-example-my-new-icon',
),
)
)
// You can also use custom icon providers and custom options
->add(
Typo3ConfigObjects\ValueObject\Icon::create('tx-example-my-new-icon')
->useCustomIconProvider(\Vendor\Example\Imaging\MyCustomIconProvider::class)
->addOption('renderer', \Vendor\Example\Renderer\MyCustomIconRenderer::class)
)
// Don't forget to return an array representation (TYPO3 expects an array to be returned)
->toArray();
```
### [`MiddlewareConfiguration`](src/Configuration/MiddlewareConfiguration.php) (for `Configuration/RequestMiddlewares.php`)
**Before:**
```php
// Configuration/RequestMiddlewares.php
use TYPO3\CMS\Core;
return [
'backend' => [
'vendor/extension/my-middleware' => [
'target' => \Vendor\Example\Middleware\MyMiddleware::class,
],
'vendor/extension/my-other-middleware' => [
'target' => \Vendor\Example\Middleware\MyOtherMiddleware::class,
'before' => [
'vendor/extension/my-middleware',
],
'after' => [
'typo3/cms-backend/authentication',
],
],
],
'frontend' => [
'typo3/cms-redirects/redirecthandler' => [
'disabled' => true,
],
],
];
```
**After:**
```php
// Configuration/RequestMiddlewares.php
use EliasHaeussler\Typo3ConfigObjects;
return Typo3ConfigObjects\Configuration\MiddlewareConfiguration::create()
// Add a list of middlewares
->addToBackendStack(
Typo3ConfigObjects\ValueObject\RequestMiddleware::create('vendor/extension/my-middleware')
->setTarget(\Vendor\Example\Middleware\MyMiddleware::class),
Typo3ConfigObjects\ValueObject\RequestMiddleware::create('vendor/extension/my-other-middleware')
->setTarget(\Vendor\Example\Middleware\MyOtherMiddleware::class)
->before('vendor/extension/my-middleware')
->after('typo3/cms-backend/authentication')
)
// You can also disable existing middlewares
->addToFrontendStack(
Typo3ConfigObjects\ValueObject\RequestMiddleware::create('typo3/cms-redirects/redirecthandler')
->disable()
)
// Don't forget to return an array representation (TYPO3 expects an array to be returned)
->toArray();
```
## 🧑💻 Contributing
Please have a look at [`CONTRIBUTING.md`](CONTRIBUTING.md).
## ⭐ License
This project is licensed under [GNU General Public License 2.0 (or later)](LICENSE).