Skip to content

Reworded the docs about storing sessions in database #12325

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

Merged
merged 1 commit into from
May 28, 2020

Conversation

javiereguiluz
Copy link
Member

This is part of our ongoing effort to reword all Doctrine related docs.

I'll summon the power of the Symfony community to review this:

The file to review is the new file session/database.rst. Here's how it looks rendered: https://github.com/javiereguiluz/symfony-docs/blob/b2ef983b79110cff8f85abeeffe78aa18f6bf31a/session/database.rst

Thank you all!

@alcaeus
Copy link
Contributor

alcaeus commented Sep 16, 2019

@alcaeus could you please review the section about MongoDB? I have some problems about the config needed to pass the MongoDB connection to MongoDBSessionHandler. Thanks!

The docs are correct per se, but there's the issue of MongoDB ODM 1.x only working with the legacy driver, which is no longer supported by the session class. We've suggested people on PHP 7 use alcaeus/mongo-php-adapter, but even then this would require using private API to retrieve the underlying \MongoDB\Client object.

The code you provided will work out of the box in MongoDB ODM 2.0, which will be released soon. Until then we're kind of stuck in limbo.

@dkarlovi
Copy link
Contributor

@javiereguiluz I'm not seeing any specific about the Redis handler?

@javiereguiluz
Copy link
Member Author

@dkarlovi maybe the new file session/database.rst is collapsed by GitHub by default? If you expand it, you'll see the first section dedicated to setting up Redis session handler.

image

Could you please check if the Redis connection setup, etc. is correct? Thanks!

@javiereguiluz
Copy link
Member Author

Thanks for the reviews!

@alcaeus I've added a note with what you said.
@dkarlovi I mentioned that you can use other Redis classes.

Copy link
Member

@stof stof left a comment

Choose a reason for hiding this comment

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

Why isn't MemcachedSessionHandler mentioned at all, while it also exists in the core ?


.. note::

MongoDB ODM 1.x only works with the legacy driver, which is no longer
Copy link
Member

Choose a reason for hiding this comment

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

Why taking about MongoDB ODM here ? This handler is not using the ODM at all.

Copy link
Contributor

Choose a reason for hiding this comment

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

The service uses the MongoDB connection service created by ODM, which is why it's worth mentioning. The alternative is creating a separate MongoDB\Client instance for use with sessions, which users may do. Maybe that's worth explaining as well?

Copy link
Member

Choose a reason for hiding this comment

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

The service uses the MongoDB connection service created by ODM, which is why it's worth mentioning.

I don't understand this statement. The MongodbSessionHandler expects a \MongoDB\Client or \MongoClient or \Mongo. It does not use the Doctrine wrappers.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this statement. The MongodbSessionHandler expects a \MongoDB\Client or \MongoClient or \Mongo.

The MongoDB session handler expects a \MongoDB\Client object since Symfony 4 - using the \MongoClient or the deprecated \Mongo class was removed in 4.0 as those classes aren't readily available on PHP 7 (as the legacy driver was never made compatible with PHP 7).

It does not use the Doctrine wrappers.

That is correct, but the service configuration shown in the docs uses the default connection that is created when using MongoDB ODM. This reuses connection info like the URL, auth details, and more to avoid users having to duplicate that info. Of course, users may very well set up a separate connection for this purpose in ODM or create their own \MongoDB\Client instance to configure the service.

One could go and set up the MongoDB session storage without ODM, but chances are people using MongoDB for session storage might also be using it for something else, in which case the ODM is the recommended way to go.

@javiereguiluz do you think there should be instructions for setting up the client without using the ODM? While I think it could be helpful for some people, I'm worried that it will confuse people as to what version to choose. On the other hand, for people that aren't using ODM this might give the impression that they need the ODM solely for the purpose of storing sessions, which is not correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm afraid I don't understand what you are discussing about. Please, tell me what should I do here: remove this note? Reword it? Thanks.

@javiereguiluz
Copy link
Member Author

@stof Memcached was a popular project a few years ago, but I think it's been overtaken by Redis:

image

I've asked on Symfony's Slack and most people seem to use Redis only.

@stof
Copy link
Member

stof commented Sep 17, 2019

I agree that Redis should be more prominent that Memcached. But given that we have support for Memcached in core, I think it deserves at least a mention in the doc.

I've asked on Symfony's Slack and most people seem to use Redis only.

with that argument to reject MemcachedHandler, why is MongodbHandler documented then ?

@HeahDude HeahDude modified the milestones: 4.3, 4.4 Feb 12, 2020
@javiereguiluz javiereguiluz changed the base branch from 4.3 to 4.4 May 28, 2020 14:32
@javiereguiluz javiereguiluz requested a review from xabbuh as a code owner May 28, 2020 14:32
@javiereguiluz javiereguiluz changed the base branch from 4.4 to 4.3 May 28, 2020 14:33
@javiereguiluz javiereguiluz changed the base branch from 4.3 to 4.4 May 28, 2020 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants