I'm installing self created extensions in TYPO3. My composer.json file ar location /var/www/html/typo3 looks like:
{
"repositories": [{
"type": "composer",
"url": "https://composer.typo3.org/"
},
{
"type": "package",
"package": {
"name": "Bm/ah-content-api",
"version": "0.0.1",
"type": "typo3-cms-extension",
"source": {
"url": "https://user@bitbucket.org/company/ah_config_typo3.git",
"type": "git",
"reference": "master"
},
"autoload": {
"psr-4": {
"bm\\ah-content-api\\": "typo3conf/ext/ah-contentapi/Classes"
}
}
}
},
{
"type": "package",
"package": {
"name": "Bm/ah-contentelements",
"version": "0.0.1",
"type": "typo3-cms-extension",
"source": {
"url": "https://user@bitbucket.org/company/ah_contentelements_typo3.git",
"type": "git",
"reference": "master"
},
"autoload": {
"psr-4": {
"bm\\ah-contentelements\\": "typo3conf/ext/ah-contentelements/Classes",
}
}
}
}
],
"name": "typo3/cms-base-distribution",
"description": "TYPO3 CMS Base Distribution",
"license": "GPL-2.0-or-later",
"require": {
"helhum/typo3-console": "^4.9.3 || ^5.2",
"typo3/cms-about": "^8.7.10",
"typo3/cms-belog": "^8.7.10",
"typo3/cms-beuser": "^8.7.10",
"typo3/cms-context-help": "^8.7.10",
"typo3/cms-documentation": "^8.7.10",
"typo3/cms-felogin": "^8.7.10",
"typo3/cms-fluid-styled-content": "^8.7.10",
"typo3/cms-form": "^8.7.10",
"typo3/cms-func": "^8.7.10",
"typo3/cms-impexp": "^8.7.10",
"typo3/cms-info": "^8.7.10",
"typo3/cms-info-pagetsconfig": "^8.7.10",
"typo3/cms-rte-ckeditor": "^8.7.10",
"typo3/cms-setup": "^8.7.10",
"typo3/cms-sys-note": "^8.7.10",
"typo3/cms-t3editor": "^8.7.10",
"typo3/cms-tstemplate": "^8.7.10",
"typo3/cms-viewpage": "^8.7.10",
"typo3/cms-wizard-crpages": "^8.7.10",
"typo3/cms-wizard-sortpages": "^8.7.10",
"dmitryd/typo3-realurl": "2.*",
"GridElementsTeam/Gridelements": "8.2.*",
"clickstorm/cs_seo": "3.*",
"Bm/ah-content-api": "0.0.1",
"Bm/ah-contentelements": "0.0.1"
},
"scripts": {
"typo3-cms-scripts": [
"typo3cms install:fixfolderstructure",
"typo3cms install:generatepackagestates"
],
"post-autoload-dump": [
"@typo3-cms-scripts"
]
},
"extra": {
"typo3/cms": {
"web-dir": "public"
},
"helhum/typo3-console": {
"comment": "This option is not needed ay more for helhum/typo3-console 5.x",
"install-extension-dummy": false
}
}
}
The data for the extensions are stored in the git repos. With each a composer.json file in the root:
{
"name": "Bm/ah-contentelements",
"type": "typo3-cms-extension",
"description": "descr,
"homepage": "http://www.company.de/",
"suggest": {
},
"require": {
"typo3/cms-core": ">=8.0.0,<9.0"
},
"author": [
{
"name": "name",
"email": "sdsd@company.de"
}
],
"autoload": {
"psr-4": {
"Bm\\AhContentelements\\": "Classes/"
}
}
}
and
{
"name": "bm/ah-content-api",
"type": "typo3-cms-extension",
"description": "Content API Extension",
"homepage": "http://www.company.de/",
"license": [
"GPL-2.0+"
],
"require": {
"typo3/cms-core": ">=7.5.0,<9.0"
},
"autoload": {
"psr-4": {
"Bm\\AhContentapi\\": "Classes/"
}
},
"replace": {
"ah_contentapi": "self.version",
"typo3-ter/ah_contentapi" : "self.version"
}
}
I ran following commands:
sudo composer update
sudo composer dump-autoload
Still there are classes not available in TYPO3.
Error message when I try to run:
#1411840171: The class "Bm\AhContentelements\Rendering\VideoTagRenderer" you are trying to register is not available
I'm using TYPO3 8.7.26
VideoTagRenderer:
<?php
namespace Bm\AhContentelements\Rendering;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Resource\FileInterface;
use TYPO3\CMS\Core\Resource\FileReference;
/**
* Class VideoTagRenderer
*/
class VideoTagRenderer extends \TYPO3\CMS\Core\Resource\Rendering\VideoTagRenderer
{
/**
* Mime types that can be used in the HTML Video tag
*
* @var array
*/
protected $possibleMimeTypes = ['video/mp4', 'video/webm', 'video/quicktime', 'video/ogg', 'application/ogg'];
/**
* Returns the priority of the renderer
* This way it is possible to define/overrule a renderer
* for a specific file type/context.
* For example create a video renderer for a certain storage/driver type.
* Should be between 1 and 100, 100 is more important than 1
*
* @return int
*/
public function getPriority()
{
return 2;
}
/**
* Check if given File(Reference) can be rendered
*
* @param FileInterface $file File or FileReference to render
* @return bool
*/
public function canRender(FileInterface $file)
{
return in_array($file->getMimeType(), $this->possibleMimeTypes, true);
}
/**
* Render for given File(Reference) HTML output
*
* @param FileInterface $file
* @param int|string $width TYPO3 known format; examples: 220, 200m or 200c
* @param int|string $height TYPO3 known format; examples: 220, 200m or 200c
* @param array $options controls = TRUE/FALSE (default TRUE), autoplay = TRUE/FALSE (default FALSE), loop = TRUE/FALSE (default FALSE)
* @param bool $usedPathsRelativeToCurrentScript See $file->getPublicUrl()
* @return string
*/
public function render(FileInterface $file, $width, $height, array $options = [], $usedPathsRelativeToCurrentScript = false)
{
// If autoplay isn't set manually check if $file is a FileReference take autoplay from there
if (!isset($options['autoplay']) && $file instanceof FileReference) {
$autoplay = $file->getProperty('autoplay');
if ($autoplay !== null) {
$options['autoplay'] = $autoplay;
}
}
$attributes = [];
if ((int)$width > 0) {
$attributes[] = 'width="' . (int)$width . '"';
}
if ((int)$height > 0) {
$attributes[] = 'height="' . (int)$height . '"';
}
if (!isset($options['controls']) || !empty($options['controls'])) {
$attributes[] = 'controls';
}
if (!empty($options['autoplay'])) {
$attributes[] = 'autoplay';
}
if (!empty($options['muted'])) {
$attributes[] = 'muted';
}
if (!empty($options['loop'])) {
$attributes[] = 'loop';
}
foreach (['class', 'dir', 'id', 'lang', 'style', 'title', 'accesskey', 'tabindex', 'onclick'] as $key) {
if (!empty($options[$key])) {
$attributes[] = $key . '="' . htmlspecialchars($options[$key]) . '"';
}
}
$extension = $file->getExtension();
if ('ogv' == $extension) {
$extension = 'ogg';
}
$useMimetype = 'video/'.$extension;
return sprintf(
'<video%s><source src="%s" type="%s"></video>',
empty($attributes) ? '' : ' ' . implode(' ', $attributes),
htmlspecialchars($file->getPublicUrl($usedPathsRelativeToCurrentScript)),
$useMimetype
);
}
}
As mentioned in the linked article: The problem is that the composer.json in you packages are ignored.
Instead you have to set the correct psr-4 in your main composer.json file. I fixed the provided snippet to match it:
http://blog.pepa.info/php-html-css/composer/composer-not-autoloading-your-package/
Sidenote: Remove the extra > helhum/typo3-console part || It's not needed anymore
Edit 1:
As long as the extensions are already part of your vcs code (checked in) you can simply avoid the repository part and simply add the following to your main composer.json file:
If the extensions are NOT part of your vcs/git repo you can simply use a convention from version 9 and extract your own extensions in a folder named Packages/ your TYPO3 root directory. Then you add the following "repository" entry instead of your current package entries:
After the next composer run you should see your extensions linked now.
Remember three things:
composer install
andcomposer update