Project

General

Profile

Actions

Feature #97264

open

ext_localconf.php architecture with namespaces

Added by Gabriel Kaufmann / Typoworx NewMedia about 2 years ago. Updated about 2 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2022-03-31
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

I noticed from TYPO3 v11 there is an updated best-practice architecture for handling with ext_localconf.php. I'm referring to this document:
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/ConfigurationFiles/Index.html

Mentioning NOT to use global namespaces to avoid namespace nesting. This is correct, but I think it would be a better approach to use classified namespaces for the extension vendor/extension key:

like this:

<?php
namespace My\FooBarExt {
  use TYPO3\CMS\Core\Utility\VersionNumberUtility;
  use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

  defined('TYPO3_MODE') || die('Access denied.');

  (function ($extKey) {
    // ... here is what usually is inside ext_localconf.php
  })('my_foobar_ext');
}

I would much more favor to replace ext_localconf.php with a Package-Registration File/Class that looks like those one used in Symfony or Laravel Packages being able to configure f.e. Site YAML (site-package config & extension routes) and services provided by the package.

This would follow more the new approach to go with Symfony/HTTP-Foundation coding standards. Here's an example for a ServiceProvider from laravel which I really like for how it is handling package (aka extension) registration:

https://laravelpackage.com/03-service-providers.html#creating-a-service-provider

Please drop me some constructive feedback. Please let me know if there are plausible reasons NOT to use any php namespace wrapping in ext_localconf.php or is this only meant for the global "namespace {}" without classified name?

Actions #1

Updated by Gabriel Kaufmann / Typoworx NewMedia about 2 years ago

Just noticed another docu targeting TYPO3 v11.4 which also targets the namespace handling:
https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/11.4/Important-94280-MoveContentsOfExtPhpIntoLocalScopes.html

Example code from the cache file:
```
namespace {
// Content of EXT:frontend/ext_localconf.php
}
```

Will this namespace be wrapped automatically by core around the ext_localconf.php code so that any namespace in ext_localconf.php will be wrapped inside (therefore nested)?

I still favor for the possibility to use classified namespaces and may be handle those ext_localconf.php with their own package-namespace (either by automatically if unset or manual from ext_localconf.php if given).

Glad to hear feedback to this.

Actions #2

Updated by Stefan Bürk about 2 years ago

  • Tracker changed from Epic to Feature
Actions #3

Updated by Simon Schaufelberger about 2 years ago

  • Description updated (diff)
Actions #4

Updated by Simon Schaufelberger about 2 years ago

@Gabriel: This issue tracker doesn't support markdown, please use the "pre" tag for it. See toolbar how to make syntax highlighting.

AFAIK the goal is to get rid of ext_* files completely in the long run and configure everything with symfony services. See https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-96733-NewBackendModuleRegistrationAPI.html in which direction it goes.

Actions

Also available in: Atom PDF