Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

[WIP] fix 'alias already exists errors' #74

Closed
wants to merge 3 commits into from

Conversation

svycka
Copy link

@svycka svycka commented Mar 19, 2018

does not need those options becouse already defined here https://github.com/zendframework/zend-expressive/blob/2.2.1/src/ConfigProvider.php#L39-L42 and throws those exceptions

An alias by the name "zendexpressivedelegatenotfounddelegate" or "Zend\Expressive\Delegate\NotFoundDelegate" already exists
An alias by the name "zendexpressivemiddlewareimplicitheadmiddleware" or "Zend\Expressive\Middleware\ImplicitHeadMiddleware" already exists 
An alias by the name "zendexpressivemiddlewareimplicitoptionsmiddleware" or "Zend\Expressive\Middleware\ImplicitOptionsMiddleware" already exists

this should be rebased and merged only to 0.4 version

@@ -56,6 +57,9 @@ class Generator implements Constants
// Override the following to use an alternate "not found" delegate.
NotFoundDelegate::class => NotFoundDelegateFactory::class,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this still causes An alias by the name "zendexpressivedelegatenotfounddelegate" or "Zend\Expressive\Delegate\NotFoundDelegate" already exists but don't know if I can remove it or have to change to something else @weierophinney can you help?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where/when do you get that error message, exactly?

I'm reviewing the slack conversation where you detail these problems, and I'm having trouble understanding how they could happen in the first place. Configuration such as this is aggregated during bootstrapping before seeding the container itself. If you're getting such messages, it's usually an indication that you're manually building your container.

Can you provide a bit more context, please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it when helping to fix this Naktibalda/codeception-zend-expressive-tests#7 I was able to fix it by requiring servicemanager v3 but expressive should work with any PSR-7 container implementation and when SM2 I get those errors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, then this may be a moot issue.

Expressive v2 releases do not support zend-servicemanager v2. They pin to v3 releases (see here and here. While Expressive v1 releases supported zend-servicemanager v2, we dropped support for those versions specifically because of discrepancies in how they operate in relation to v3.

If the error only occurs when using zend-servicemanager v2, then we can close this issue; we do not support that version in releases where this tooling would be relevant.

Copy link
Author

@svycka svycka Mar 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes the error only exists with SM v2 but I do not understand if zend-expressive supports any PSR-11 implementation and SeriviceManager v2 is PSR-11 implementation then why it does not work? maybe other also will not work?
I don't fully understand the situation here, but if you think this not an issue feel free to close this as I already using expressive3

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a matter of whether or not both are PSR-11 compatible; for that purpose, the has() and get() methods of each operate identically.

The issue is that zend-servicemanager v2 and v3 have a few differences in how they handle container population, with v3 fixing issues in v2 that we could not address without a BC break. One of these is how it identifies service conflicts during initial configuration. v3 has a better algorithm — but it's one we cannot backport, as it introduces BC breaks elsewhere. For this reason, we chose to only support zend-servicemanager v3 in Expressive v2 and up.

@weierophinney weierophinney changed the base branch from master to release-0.4 March 19, 2018 13:38
@@ -56,6 +57,9 @@ class Generator implements Constants
// Override the following to use an alternate "not found" delegate.
NotFoundDelegate::class => NotFoundDelegateFactory::class,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where/when do you get that error message, exactly?

I'm reviewing the slack conversation where you detail these problems, and I'm having trouble understanding how they could happen in the first place. Configuration such as this is aggregated during bootstrapping before seeding the container itself. If you're getting such messages, it's usually an indication that you're manually building your container.

Can you provide a bit more context, please?

@@ -33,6 +33,7 @@ class Generator implements Constants
use Zend\Expressive\Middleware\ImplicitHeadMiddleware;
use Zend\Expressive\Middleware\ImplicitOptionsMiddleware;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change these to reference the zend-expressive-router variants, and also import their factories; the changes starting at line 60 then need updating.

@@ -12,6 +12,7 @@
use Zend\Expressive\Middleware\ImplicitHeadMiddleware;
use Zend\Expressive\Middleware\ImplicitOptionsMiddleware;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the above two lines.

@@ -23,7 +23,7 @@
"symfony/console": "^2.8 || ^3.0 || ^4.0",
"zendframework/zend-code": "^3.1 || ^2.6.3",
"zendframework/zend-component-installer": "^1.0 || ^0.7.1",
"zendframework/zend-expressive": "^2.0",
"zendframework/zend-expressive": "^2.2",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weierophinney should I update composer.lock?

@svycka svycka changed the title fix 'alias already exists errors' [WIP] fix 'alias already exists errors' Mar 20, 2018
@weierophinney
Copy link
Member

Closing.

As noted in comments above, it turns out that this issue only arises when using zend-servicemanager v2 — which Expressive versions 2 and above no longer support due to differences in how the v2 vs v3 containers populate themselves from configuration.

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

Successfully merging this pull request may close these issues.

None yet

2 participants