Skip to content

Update composer.json for Symfony 4. #211

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

Closed
wants to merge 6 commits into from
Closed

Update composer.json for Symfony 4. #211

wants to merge 6 commits into from

Conversation

dbrumann
Copy link

@dbrumann dbrumann commented Oct 22, 2017

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets ---
Documentation ---
License MIT

What's in this PR?

Update Symfony-related dependencies to allow 4.x-versions to make this bundle work in Symfony 4.0 applications. This PR requires php-http/stopwatch-plugin#4 to work.

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Thank you.

I think you also need to add the following to composer.json:

"minimum-stability": "dev",
"prefer-stable": true,

..else it will not take the dev dependencies.

.travis.yml Outdated
@@ -33,6 +33,8 @@ matrix:
# Test against LTS versions
- php: 7.0
env: SYMFONY_VERSION=2.8.*
- php: 7.1
env: SYMFONY_VERSION=4.0.*
Copy link
Member

Choose a reason for hiding this comment

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

Write version 3.4 here instead. Then add another entry for 4.0 above the comment say "Test against LTS versions"

@soullivaneuh
Copy link
Contributor

@dbu
Copy link
Collaborator

dbu commented Nov 13, 2017

can you please rebase this on master? i just merged #216 which should fix the fatal error.

@dbu
Copy link
Collaborator

dbu commented Nov 13, 2017

and we need to figure out if we simply need to make those services public that we get warnings for in symfony 3.4, or if we can wire things so as to not need to get those service from the container but inject them instead.

@fbourigault
Copy link
Contributor

All services the container complains about have to be public to keep backward compatibility!

@dbu
Copy link
Collaborator

dbu commented Nov 13, 2017

All services the container complains about have to be public to keep backward compatibility!

they only become inaccessible in symfony 4, so thats no BC break of us. discusssion is in #218, it looks like most of them are explicitly set to private...

@fbourigault
Copy link
Contributor

But I think we want to support Symfony 2.8 -> 4.0 in next minor release?

@xabbuh
Copy link
Member

xabbuh commented Nov 22, 2017

@dbrumann Any updates? Will you be able to work on this? :)

@dbrumann
Copy link
Author

Very funny @xabbuh. I will update this PR on Friday

@dbu
Copy link
Collaborator

dbu commented Nov 22, 2017

support Symfony 2.8 - 4.0 in next minor release?

unless there is a big problem popping up with that yes, i would want to support all those.

when the user updates to symfony 4, services that have been public only by accident will become private, which is imo a BC break of symfony itself, not of this bundle, and thus seems acceptable. we should nonetheless list the services in the changelog to help the users with upgrading.

composer.json Outdated
@@ -42,13 +42,13 @@
"php-http/buzz-adapter": "^0.3",
"php-http/mock-client": "^1.0",
"symfony/phpunit-bridge": "^3.2",
Copy link
Member

Choose a reason for hiding this comment

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

What about allowing 4.0 here too?

@dbu
Copy link
Collaborator

dbu commented Nov 24, 2017

i think the version 4 can't install because one of our dependencies does not support it. do you see which one it is?

the 3.4 build has warnings about accessing private services. i think the httplug clients should be public. for the rest we have to see, we maybe also need to change some tests to not try to get the service from the container in this way.

@Nyholm
Copy link
Member

Nyholm commented Nov 25, 2017

@dbrumann Do you mind if I try to make this work?

@dbrumann
Copy link
Author

@Nyholm Not at all. Since prophecy and phpspec merged the Symfony 4 updates I should be able to make php-http/stopwatch-plugin pass now and then hopefully this PR as well, but feel free to add commits. I will refrain from doing any changes requiring a force push.

@Nyholm
Copy link
Member

Nyholm commented Nov 25, 2017

Much cleaner, thank you!

@Nyholm
Copy link
Member

Nyholm commented Nov 25, 2017

I think you are done with this PR. You are blocked by #221. When that PR is merged you just have to rebase and everything will be green

@Nyholm
Copy link
Member

Nyholm commented Nov 27, 2017

Hey @dbrumann. If you do a final rebase on master then you should be just fine. I've updated .travis.yml to test all proper symfony versions.

@fbourigault fbourigault added this to the 1.8.0 milestone Nov 27, 2017
Copy link
Collaborator

@dbu dbu left a comment

Choose a reason for hiding this comment

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

thanks a lot @dbrumann ! i think we should make httplug.client (and httplug.async_client?) public as well. for the other point about plugins i am ok if we merge as is but think we should then try to change that in a separate PR so they can be completely wired in the container rather than need to be public.

@@ -24,17 +24,17 @@ public function testHttpClient()
{
static::bootKernel();
$container = static::$kernel->getContainer();
$this->assertTrue($container->has('httplug.client'));
$client = $container->get('httplug.client');
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think we should make the httplug.client service public too, it seems correct to me to reference it by that name.

Copy link
Author

Choose a reason for hiding this comment

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

According to the current configuration it is configured as private. I can restore this test, but then I would also change the public=false in the service configuration to make clear that this id can be used.

@@ -26,3 +26,4 @@ httplug:
services:
app.http.plugin.custom:
class: Http\Client\Common\Plugin\RedirectPlugin
public: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do the plugins need to be public? that smells like an issue in how we wire them into the plugin-client, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't just because test assertions are written against the compiled container instead of the container builder?

Copy link
Collaborator

Choose a reason for hiding this comment

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

indeed, seems the problem is in ServiceInstantiationTest::testProfilingShouldNotChangeServiceReference where we get the container from the kernel and then assert that nothing messes with the plugin service. i don't know if there is an easy solution for this - maybe simply add a comment here to avoid confusion? # plugin services usually do not need to be public. this one is made public so that we can do functional tests on the service

Copy link
Member

Choose a reason for hiding this comment

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

That's basically the approach we still need to document with now "private by default" services in Symfony 4 (see symfony/symfony-docs#8097). In this case, we do not need to work around with an alias.

Copy link
Author

Choose a reason for hiding this comment

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

Are there any preferences as to whether I should use a test alias or just add a comment? I personally prefer the comment. Making this public for tests because we want to get it from the container feels more honest to me.

Copy link
Member

Choose a reason for hiding this comment

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

The alias IMO is only needed when the service would be present outside the test too (which is not the case here).

Copy link
Collaborator

Choose a reason for hiding this comment

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

agreed, lets just add a comment

<factory class="Http\Discovery\HttpClientDiscovery" method="find" />
</service>
<service id="Http\Client\HttpClient" alias="httplug.client" public="false" />
<service id="Http\Client\HttpClient" alias="httplug.client" public="true" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

hm, is this what we need to make public? this is just the alias to enable autowiring. this is not defining httplug.client

Copy link
Member

Choose a reason for hiding this comment

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

I agree. These aliases shouldn't be public (in Symfony, they are private too).

@dbu
Copy link
Collaborator

dbu commented Nov 28, 2017

i looked at the code and don't see where the service httplug.client is defined. its neither in services.xml nor in the HttplugExtension, it seems

@Nyholm
Copy link
Member

Nyholm commented Nov 28, 2017

The httplug.client definition is super old code..

It is defined here: https://github.com/php-http/HttplugBundle/blame/v1.7.1/DependencyInjection/HttplugExtension.php#L53

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

As a second thought.. Why do we need any service to be public?

One should never do $this->container->get($service).

Do we specify them public here to allow the tests to pass?

@fbourigault
Copy link
Contributor

I think we should follow the Symfony 4 trend and let those service became private in Symfony 4. Users will get deprecation notices if getting those services using ContainerInterface::get.

For the test, could we rewrite it to not write assertion on compiled container? If no adding a comment where the public=true is set would be great!

@fbourigault
Copy link
Contributor

Could you rebase again to get #225 and really run tests against Symfony 4?

@Nyholm
Copy link
Member

Nyholm commented Nov 29, 2017

Thank you @dbrumann. This was merged via #228.

@dbrumann dbrumann deleted the update/symfony4 branch November 30, 2017 02:16
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

Successfully merging this pull request may close these issues.

6 participants