I tested this a while ago, but now I get errors with 9.5.13:
Fatal error: Cannot use TYPO3\CMS\Core\Utility\GeneralUtility as GeneralUtility
because the name is already in use in
/var/www/mysite/public/typo3temp/var/cache/code/cache_core/ext_localconf_feb178af00fe22e00dc62d7dcd6d4d16f5d4fc3a.php
on line 4508
The problematic line:
4496 /**
4497 * Extension: distributed-locks
4498 * File: /var/www/mysite/public/typo3conf/ext/distributed-locks/ext_localconf.php
4499 */
4500
4501 $_EXTKEY = 'distributed-locks';
4502 $_EXTCONF = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY] ?? null;
4503
4504
4505
4506 defined('TYPO3_MODE') or die();
4507
4508 use TYPO3\CMS\Core\Utility\GeneralUtility;
4509 use TYPO3\CMS\Core\Locking\LockFactory;
4510 use B13\DistributedLocks\RedisLockingStrategy;
ext_localconf.php contains use statements. Since multiple ext_localconf.php are concatenated into one this may cause problems if more than one extension uses the same use statement.
I believe, the recommended solution is to enclose this in a function:
<?php
defined('TYPO3_MODE') || die();
(function () {
// Add your code here
// use ....
})();
You must never use a use statement in the files global scope - that would make the cached script concept break and could conflict with other extensions.
I tested this a while ago, but now I get errors with 9.5.13:
The problematic line:
ext_localconf.php contains use statements. Since multiple ext_localconf.php are concatenated into one this may cause problems if more than one extension uses the same use statement.
I believe, the recommended solution is to enclose this in a function:
see https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ExtensionArchitecture/ConfigurationFiles/Index.html