pdfviewhelpers icon indicating copy to clipboard operation
pdfviewhelpers copied to clipboard

[composer] Warning: Ambiguous class resolution

Open xerc opened this issue 5 years ago • 5 comments

PHP 7.3 composer 1.10.5

typo3/cms-core [10.4.9]
helhum/typo3-secure-web [0.2.11]
bithost-gmbh/pdfviewhelpers [2.3.4]

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/include/barcodes/datamatrix.php vendor/tecnickcom/tcpdf/include/barcodes/datamatrix.php

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/include/barcodes/pdf417.php vendor/tecnickcom/tcpdf/include/barcodes/pdf417.php

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/include/barcodes/qrcode.php vendor/tecnickcom/tcpdf/include/barcodes/qrcode.php

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/include/tcpdf_colors.php vendor/tecnickcom/tcpdf/include/tcpdf_colors.php

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/include/tcpdf_filters.php vendor/tecnickcom/tcpdf/include/tcpdf_filters.php

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/include/tcpdf_font_data.php vendor/tecnickcom/tcpdf/include/tcpdf_font_data.php

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/include/tcpdf_fonts.php vendor/tecnickcom/tcpdf/include/tcpdf_fonts.php

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/include/tcpdf_images.php vendor/tecnickcom/tcpdf/include/tcpdf_images.php

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/include/tcpdf_static.php vendor/tecnickcom/tcpdf/include/tcpdf_static.php

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/tcpdf.php vendor/tecnickcom/tcpdf/tcpdf.php

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/tcpdf_parser.php vendor/tecnickcom/tcpdf/tcpdf_parser.php

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/tcpdf_import.php vendor/tecnickcom/tcpdf/tcpdf_import.php

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/tcpdf_barcodes_1d.php vendor/tecnickcom/tcpdf/tcpdf_barcodes_1d.php

source/typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/tcpdf_barcodes_2d.php vendor/tecnickcom/tcpdf/tcpdf_barcodes_2d.php

xerc avatar Nov 02 '20 12:11 xerc

@maechler If TCPDF is required by another composer package too, the files will be once in the ./vendor/ directory and once in ./typo3conf/ext/pdfviewhelpers/Resources/Private/PHP/tcpdf/. In the TER package, TCPDF must be included in the package but for composer installations, only tecnickcom/tcpdf should be defined as requirement in the composer.json file.

aimeos avatar Nov 03 '20 07:11 aimeos

@xerc @aimeos Thanks for reporting this issue! I am aware of this issue, unfortunately I have not yet found a way to solve this.

The problem is that TYPO3 relies on the composer.json file for generating the autoload information even if not run in composer mode. If we removed the following line, then autoloading would not work anymore in non composer mode:

https://github.com/bithost-gmbh/pdfviewhelpers/blob/d9fa9a8726a2ade80bbed249ba31b484179ee057/composer.json#L31

At the moment I see only two options to solve this:

  1. Try not to use the extension that also requires TCPDF in its composer.json
  2. Fork either EXT:pdfviewhelpers or that other package and edit the composer.json to fit your needs

If you see another option, then please let me know! I think that for v3 of pdfviewhelpers we should remove the TCPDF and FPDI source files from the extension and provide installation instructions for non composer users.

maechler avatar Nov 03 '20 14:11 maechler

@maechler A simple solution is to leave the directories listed in the classmap empty by default and only add the source code of tcpdf and fpdi in the package uploaded to TER. We do this in the same way and use a build script that automates adding additional source code. This is an excerpt of our phing build script:

<?xml version="1.0" encoding="UTF-8"?>

<project name="Aimeos TYPO3 extension" default="update">
	<target name="composer" description="Updates composer dependencies">
		<delete dir="Resources/Libraries" includeemptydirs="true" />
		<exec command="composer remove --no-update --working-dir ${project.basedir} typo3/cms-core typo3/cms-backend typo3/cms-extbase typo3/cms-scheduler bithost-gmbh/pdfviewhelpers sjbr/static-info-tables" checkreturn="true" logoutput="true" />
		<exec command="composer update --no-dev --no-autoloader --working-dir ${project.basedir}" checkreturn="true" logoutput="true" passthru="true" />
		<exec command="rm -rf Resources/Libraries/tecnickcom/" checkreturn="true" logoutput="true" />
		<exec command="composer dump-autoload --working-dir ${project.basedir}" checkreturn="true" logoutput="true" />
		<exec command="git checkout composer.json" checkreturn="true" logoutput="true" />
	</target>
</project>

aimeos avatar Nov 05 '20 09:11 aimeos

Here are 2 approaches with custom autoloaders:

using .phar: https://insight.helhum.io/post/148112375750/how-to-include-binaries-for-ter-exts

using a separate composer.json: https://gist.github.com/cedricziel/08ea469db5197e24552c

jonaseberle avatar Nov 05 '20 09:11 jonaseberle

@aimeos @jonaseberle Thanks for the proposals! If anyone of you could prepare a pull request, I would be happy to include a fix into the extension. I would probably go for a custom composer.json and autoloader that is only used if we are not in composer mode. At the moment I am rather busy, but if none of you can work on this, I will do it sometime.

maechler avatar Nov 05 '20 14:11 maechler

Will be resolved with https://github.com/bithost-gmbh/pdfviewhelpers/issues/179.

maechler avatar Mar 20 '23 21:03 maechler