Installing an extension which uses composer in a non-composer TYPO3 installation? It is possible, as long as you make your extension autoloading compatible and pull in the dependencies.
You've created an extension for TYPO3 that uses composer, and now you want to use it in a non-composer TYPO3 installation. The first issue that you run into, is that TYPO3 does not load the class correctly. The second issue is how you get the used libraries and you can still use the benefits of package management (composer). The solution? To make an "archive" of your extension using composer. You can then use this to use TYPO3 in a non-composer installation.
In the `Resources / Private / PHP` folder you create a composer.json file that enters the external php packages. You do not have to add the dependencies on TYPO3 extensions since they are installed separately in TYPO3. After adding your dependencies you can install them via `composer install '.
After the packages have been brought in, we still have to call on the autoload so that the packages and classes are available. In TYPO3 it is recommended to do the autoload in "ext_localconf.php". If TYPO3 is not installed via composer, the packages are loaded using the following code:
Finally, you need to create an archive/zip package which you can then use to upload your extension to the extension manager or to the TER. This can be done easily via cmdline with the command:
You could optimise this by adding a script to your root composer.json file in your extension. This script will then automatically perform the composer install and archive for you:
An example where we used this principle is the Mautic-TYPO3 extension. See the commit: https://github.com/mautic/mautic-typo3/commit/fd5e5b92cc5b7e800cd6d53be2ee3b96edf4220c#diff-b5d0ee8c97c7abd7e3fa29b9a27d1780
The idea above is based on the TYPO3 extension: `https://github.com/cedricziel/typo3-ext-slugify` which makes the extension `cocur / slugify` compatible for non composer TYPO3 installation in a similar way.
Please note, the method described above can cause problems in installations where multiple identical packages are used in different extensions. It is advisable, if it allows, to proceed to install TYPO3 via composer.