Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with psr/log:^3 and maybe other problems with surf 3.4 as global composer package #760

Closed
koehnlein opened this issue May 12, 2023 · 7 comments

Comments

@koehnlein
Copy link
Contributor

koehnlein commented May 12, 2023

Expected Behavior

Surf 3.4 should work as global composer package

Actual Behavior

I have installed surf as global composer package to not run into dependency conflicts with my TYPO3 installation. But with the newest surf version 3.4, all surf commands result in the same PHP error, even surf --version

PHP Fatal error: Declaration of TYPO3\Surf\Domain\Service\ShellCommandService::setLogger(Psr\Log\LoggerInterface $logger) must be compatible with Psr\Log\LoggerAwareInterface::setLogger(Psr\Log\LoggerInterface $logger): void in /tmp/vendor/typo3/surf/src/Integration/LoggerAwareTrait.php on line 20

The problem seems the package "psr/log". When installing surf 3.3.x, "psr/log:^2" is installed, with surf 3.4, "psr/log:^3" is installed, because I do not have any other packages installed, that set any required "psr/log" version.

After locking "psr/log" to version ^2, the error disappears, but I see the next PHP error message:

PHP Fatal error: Cannot redeclare TYPO3\Surf\findAllReleases() (previously declared in /tmp/vendor/typo3/surf/src/functions.php:24) in /tmp/vendor/typo3/surf/src/functions.php on line 24

But I have absolute no idea, what's wrong here.

Steps to Reproduce the Problem

  1. composer global req typo3/surf:^3.4
  2. surf --version

Specifications

  • Surf Version: 3.4
  • Application:
  • PHP Version: 8.2
  • Platform:
  • Environment (CI):
  • Deployment configuration:
@koehnlein koehnlein changed the title Not compatible with psr/log:^3 and maybe other problems Not compatible with psr/log:^3 and maybe other problems with surf 3.4 as global composer package May 12, 2023
@jonaseberle
Copy link
Contributor

jonaseberle commented May 17, 2023

I just really wouldn't use it as a global composer package. composer can't handle different dependency versions so it is just not a good choice for anything global IMHO.

I would even keep it separate from your TYPO3 or any other app. It's a stand-alone app.

If you really want it in the same project but without dependency hell, https://packagist.org/packages/bamarni/composer-bin-plugin can help.

Your general dependency problem might be valid of course.
monolog/monolog ^2.9.1 requires psr/log: ^1.0.1 || ^2.0 || ^3.0 and 3.0 introduced the return type (void) in that interface.
So I suggest Surf should require psr/log: ^1.0.1 || ^2.0.

@koehnlein
Copy link
Contributor Author

I would even keep it separate from your TYPO3 or any other app. It's a stand-alone app.

I have a container for deployment with pre-installed surf as only global composer package. So it is de facto stand-alone. Similar to https://github.com/t3easy/docker-surf/blob/main/Dockerfile#L30

@sabbelasichon
Copy link
Collaborator

@koehnlein The MR #770 should fix the issue. Could you try the latest release for me please.

@koehnlein
Copy link
Contributor Author

@sabbelasichon Thanks. The psr/log problem is solved now.

I still run into the other problem

PHP Fatal error: Cannot redeclare TYPO3\Surf\findAllReleases() (previously declared in /tmp/vendor/typo3/surf/src/functions.php:24) in /tmp/vendor/typo3/surf/src/functions.php on line 24

This seems to be a composer autoloading issue. I will open a new issue for that, if I could find out more.

@sabbelasichon
Copy link
Collaborator

I have run into the same issue yesterday and fixed it. I am going to publish a new release soon.

@sabbelasichon
Copy link
Collaborator

@koehnlein I have create another release 3.4.2. This should fix the last issue.

@koehnlein
Copy link
Contributor Author

@sabbelasichon Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants