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

Version 3.11 conflicts with ext-psr #124

Closed
remicollet opened this issue Apr 7, 2022 · 22 comments · Fixed by #125
Closed

Version 3.11 conflicts with ext-psr #124

remicollet opened this issue Apr 7, 2022 · 22 comments · Fixed by #125
Assignees
Labels
Bug Something isn't working
Milestone

Comments

@remicollet
Copy link
Contributor

When psr extension is loaded

Fatal error: Uncaught ValueError: class_alias(): Argument #1 ($class) must be a user-defined class name, internal class name given in ......src/autoload.php:13

so class_alias cannot be used there

@remicollet
Copy link
Contributor Author

Using old code (in src/autoload) can be a workaround

namespace Interop\Container;

interface ContainerInterface extends \Psr\Container\ContainerInterface {
}

namespace Interop\Container\Exception;

use Psr\Container\ContainerExceptionInterface as PsrContainerException;
use Psr\Container\NotFoundExceptionInterface as PsrNotFoundException;

interface ContainerException extends PsrContainerException
{
}	
interface NotFoundException extends ContainerException, PsrNotFoundException
{
}

BTW, I don't see any real benefit in replacing container-interop, user simply should switch away from it, and composer display a warning about this when installed

Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.

@Ocramius
Copy link
Member

Ocramius commented Apr 7, 2022

@remicollet the reason why we did replace is for BC specifically: we wanted to be able to migrate to psr/container:^2, and we couldn't due to no movement on container-interop/container-interop.

Dropping container-interop is not viable due to the amount of downstream factories and inheritance-based designs that would just break.

On this end, I must say that I didn't know that a psr extension existed, but I'd treat the BC break against that as much smaller compared to the effect of dropping container-interop/ directly (much more problematic).

One alternative we could have is to use inheritance with the PSR interfaces, as you suggested, instead of aliasing.

@Ocramius Ocramius added this to the 3.11.2 milestone Apr 7, 2022
@boesing
Copy link
Member

boesing commented Apr 7, 2022

TBH: I have no idea how to fix this.
I also don't see/understand why it is not possible to use class_alias for interfaces provided by an extension.

We also had RFC open for months, almost 1 year and there was no feedback in that direction.

That extension also is problematic when it comes to multiple major versions of the PSR standards. So until there is no dedicated extension per RFC, that extension needs to keep BC compat or a hilarious amount of versions to reflect all version combinations.

Given the fact, that there are 3 major versions for psr/cache, that extension will block any user from migrating to any newer version. Therefore, I would conflict with that extension. Sadly, we haven't done this in the X.X.0 minor release already, therefore it will install until we do conflict.

@Ocramius
Copy link
Member

Ocramius commented Apr 7, 2022

Adding "conflict": {"ext-psr": "*"} is a viable solution, for now.

@boesing
Copy link
Member

boesing commented Apr 7, 2022

Adding "conflict": {"ext-psr": "*"} is a viable solution, for now.

Yes, but that will only apply to the 2nd patch of the minor. So 1st patch still installable. :-/

Given the fact, that there are 3 major versions for psr/cache, that extension will block any user from migrating to any newer version.

Only for all 3 psr/cache versions + all psr/container versions, there need to be these major versions of the extension:

  • one with psr/cache v1 + psr/container v1
  • one with psr/cache v1 + psr/container v2
  • one with psr/cache v2 + psr/container v1
  • one with psr/cache v2 + psr/container v2
  • one with psr/cache v3 + psr/container v1
  • one with psr/cache v3 + psr/container v2

You see where this is going, right? I would not use such extension.

@Ocramius
Copy link
Member

Ocramius commented Apr 7, 2022

So 1st patch still installable. :-/

Yes, but we can't do much about that anyway. Let's just declare the conflict, since bug reports need to target the latest patch release anyway, in order to be considered: at least we declared where we stand.

@boesing
Copy link
Member

boesing commented Apr 7, 2022

Guess this issue reported here also covers the error "reported" in the commit:
4756d91#commitcomment-70569233

boesing added a commit to boesing/laminas-servicemanager that referenced this issue Apr 7, 2022
…ias` to a non-user interface

There is a PHP extension around which provides all (most?) PSR interfaces without the need of installing them via composer. Since we do not support this extension and since that extension does not make sense anyways (more details later), we explicitly adding a `conflict` to the `composer.json` so that there are no surprises for projects which do have the `psr` extension installed.

closes laminas#124

Now to the problem with the extension:

There are multiple PSR standards around. Many of them do have multiple major versions around. The extension has to follow semver to avoid breaks in upstream projects. So as of now (v1.2.0), it only provides the interfaces for the v1 versions of the PSR standards.
There is no way to provide multiple major versions of the same PSR interface from within one version of the extension.
Therefore, at some point, an upstream project is either stuck with the v1 versions of the PSR standards or the extension needs to create a hilarious amount of major versions to reflect all possible combinations of all major versions (cartesian product).

Lets just take the PSR-11 + PSR-6 example, we already would have 6 major versions around because PSR-11 has 2 major versions and PSR-6 has 3 major versions:

- psr/cache 1.x + psr/container 1.x
- psr/cache 1.x + psr/container 2.x
- psr/cache 2.x + psr/container 1.x
- psr/cache 2.x + psr/container 2.x
- psr/cache 3.x + psr/container 1.x
- psr/cache 3.x + psr/container 2.x

And these are only 2 packages. I lost track on the current progress, but there will be more major versions in the future and thus the amount of major versions for the extension will grow (and with that, the confusion for upstream projects, maintainers, etc.).

We highly recommend to use composer to install the PSR standards per package in the version the upstream project can work with.
**Do not use the `psr` extension**

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
@boesing boesing linked a pull request Apr 7, 2022 that will close this issue
@Ocramius Ocramius closed this as completed Apr 7, 2022
@Ocramius Ocramius added Bug Something isn't working and removed BC Break labels Apr 7, 2022
boesing added a commit that referenced this issue Apr 7, 2022
…ias` to a non-user interface

There is a PHP extension around which provides all (most?) PSR interfaces without the need of installing them via composer. Since we do not support this extension and since that extension does not make sense anyways (more details later), we explicitly adding a `conflict` to the `composer.json` so that there are no surprises for projects which do have the `psr` extension installed.

closes #124

Now to the problem with the extension:

There are multiple PSR standards around. Many of them do have multiple major versions around. The extension has to follow semver to avoid breaks in upstream projects. So as of now (v1.2.0), it only provides the interfaces for the v1 versions of the PSR standards.
There is no way to provide multiple major versions of the same PSR interface from within one version of the extension.
Therefore, at some point, an upstream project is either stuck with the v1 versions of the PSR standards or the extension needs to create a hilarious amount of major versions to reflect all possible combinations of all major versions (cartesian product).

Lets just take the PSR-11 + PSR-6 example, we already would have 6 major versions around because PSR-11 has 2 major versions and PSR-6 has 3 major versions:

- psr/cache 1.x + psr/container 1.x
- psr/cache 1.x + psr/container 2.x
- psr/cache 2.x + psr/container 1.x
- psr/cache 2.x + psr/container 2.x
- psr/cache 3.x + psr/container 1.x
- psr/cache 3.x + psr/container 2.x

And these are only 2 packages. I lost track on the current progress, but there will be more major versions in the future and thus the amount of major versions for the extension will grow (and with that, the confusion for upstream projects, maintainers, etc.).

We highly recommend to use composer to install the PSR standards per package in the version the upstream project can work with.
**Do not use the `psr` extension**

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
boesing referenced this issue Apr 8, 2022
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
@MeetKamal
Copy link

Hello all, have added the conflict but still getting same error :(

@Ocramius
Copy link
Member

Ocramius commented Apr 13, 2022

Are you on the latest version? Check composer show --installed: you should be on 3.11.2 or newer.

@MeetKamal
Copy link

Hi @Ocramius - Just checked the version its 3.11.1
laminas/laminas-servicemanager 3.11.1 Factory-Driven Dependency Injection Container

how we can upgrade ?

@Ocramius
Copy link
Member

By uninstalling ext-psr, for which we declared an explicit compatibility conflict 😁

@MeetKamal
Copy link

Hi @Ocramius
Thanks for the update, it seems service manager upgraded now on local.

  • Upgrading laminas/laminas-servicemanager (3.11.1 => 3.11.2)

@MeetKamal
Copy link

HI @Ocramius

Now all backend command executed, and it seems project setup . but when we go to front end its showing same error on front end

Fatal error: Uncaught ValueError: class_alias(): Argument #1 ($class) must be a user-defined class name, internal class name given in /var/www/html/m245/project-community-edition/vendor/laminas/laminas-servicemanager/src/autoload.php:1

@MeetKamal
Copy link

Fatal error: Uncaught ValueError: class_alias(): Argument #1 ($class) must be a user-defined class name, internal class name given in /var/www/html/m245/project-community-edition/vendor/laminas/laminas-servicemanager/src/autoload.php:13 Stack trace: #0 /var/www/html/m245/project-community-edition/vendor/laminas/laminas-servicemanager/src/autoload.php(13): class_alias() #1 /var/www/html/m245/project-community-edition/vendor/composer/autoload_real.php(59): require('...') #2 /var/www/html/m245/project-community-edition/vendor/composer/autoload_real.php(42): composerRequired13112b11e1877c5fa97a92a7af68de2() #3 /var/www/html/m245/project-community-edition/vendor/autoload.php(12): ComposerAutoloaderInitd13112b11e1877c5fa97a92a7af68de2::getLoader() #4 /var/www/html/m245/project-community-edition/app/autoload.php(51): include('...') #5 /var/www/html/m245/project-community-edition/app/bootstrap.php(43): require_once('...') #6 /var/www/html/m245/project-community-edition/index.php(12): require('...') #7 {main} thrown in /var/www/html/m245/project-community-edition/vendor/laminas/laminas-servicemanager/src/autoload.php on line 13

@MeetKamal
Copy link

HI @Ocramius

Please review above error and guide for the same

@andrew-demb
Copy link

@MeetKamal latest versions of package is not compatible with ext-psr.
You should uninstall it from the server. Uninstalling from developer machines is not enough.

@Ocramius
Copy link
Member

Also, only run composer install on a system that is compatible (or same) to your production environment.

@MeetKamal
Copy link

Thanks, will try on another machine. Have tried the composer install but no luck

@AkashicSeer
Copy link

AkashicSeer commented Aug 6, 2022

Can I say I am not shocked this was never fixed. Does anything work these days at all?

@Ocramius
Copy link
Member

Ocramius commented Aug 6, 2022

@AkashikSeer we explicitly declared a conflict with ext-psr: it is up to you to either downgrade this package, or uninstall ext-psr. This issue is 100% solved from this end.

@AkashicSeer
Copy link

AkashicSeer commented Aug 9, 2022 via email

@ozzpy
Copy link

ozzpy commented Aug 31, 2023

By uninstalling ext-psr, for which we declared an explicit compatibility conflict 😁

best solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants