Skip to content

Document host parameter and external parameters in "How to Use PdoSessionHandler..." #9493

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

Conversation

pueppiblue
Copy link
Contributor

I recently had the use case to store sessions via pdo on a docker grid.
I noticed the doctrine/pdo_session_storage.rst documentation is missing the option
to configure a host on the PdoSessionHandler and that
the service configuration does not use external environment parameters.

  • add host parameter to first argument
    useful when database is on another host e.g. docker grid
  • wrap parameter values in %env()%
  • add note how to use external parameters

  - add host parameter to first argument
    useful when database is on another host e.g. docker grid
  - wrap parameter values in %env()%
  - add note how to use external parameters
@xabbuh xabbuh added this to the 2.7 milestone Apr 20, 2018
array(
'db_table' => '%env(SESSIONS_TABLE)%',
'db_username' => '%env(MYDATABASE_USERNAME)%',
'db_password' => '%env(MYDATABASE_PASSWORD)'
Copy link
Contributor

Choose a reason for hiding this comment

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

The trailing comma in the last element of the arrays is missing, look #8325

Copy link
Contributor Author

@pueppiblue pueppiblue Apr 24, 2018

Choose a reason for hiding this comment

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

$container->autowire(PdoSessionHandler::class) 
            ->setArguments( \
                array( \
                    'mysql:dbname=%env(MYDATABASE_NAME)%, host=%env(MYDATABASE_HOST)%',
                    array(
                        'db_table' => '%env(SESSIONS_TABLE)%',
                        'db_username' => '%env(MYDATABASE_USERNAME)%',
                        'db_password' => '%env(MYDATABASE_PASSWORD)',
                    ), // awkward comma
                )
            );

To be really consistent, I'd to add another comma, but for me it looks kind of awkward after the closing brace.
What would you think?

@xabbuh xabbuh modified the milestones: 2.7, 3.4 May 19, 2018
@javiereguiluz
Copy link
Member

@pueppiblue thanks a lot for this contribution. I totally agree with the addition of the missing host option. Thanks for that!

However, I've reverted the other changes mainly for two reasons:

  • To not duplicate the explanation about env vars of the /configuration/external_parameters.rst article that you linked here.
  • Because it's not that simple to do now that Symfony promotes the use of database DSNs in the DATABASE_URL env var. We no longer have individual env vars for database name, host, use, etc.

In any case, thanks for your contribution and we've merged it in 3.4 (later we'll merge it in the other branches). Congrats on your Symfony Docs contribution!

javiereguiluz added a commit that referenced this pull request Jul 12, 2018
…o Use PdoSessionHandler..." (pueppiblue, javiereguiluz)

This PR was submitted for the master branch but it was merged into the 3.4 branch instead (closes #9493).

Discussion
----------

Document host parameter and external parameters in "How to Use PdoSessionHandler..."

I recently had the use case to store sessions via pdo on a docker grid.
I noticed the `doctrine/pdo_session_storage.rst` documentation is missing the option
to configure a host on the PdoSessionHandler and that
the service configuration does not use external environment parameters.

  - add host parameter to first argument
    useful when database is on another host e.g. docker grid
  - wrap parameter values in %env()%
  - add note how to use external parameters

Commits
-------

d49d8a7 Remove some unneeded changes
a7c3344 Don't use env vars in all config examples
8ea2380 add more trailing comma on last array element #9493
ba5fa52 add trailing comma on last array element #9493
e291746 codestyle
cd24113 add documentation for external parameters and pdo host parameter
javiereguiluz added a commit to javiereguiluz/symfony-docs that referenced this pull request Jul 12, 2018
* 3.4:
  Remove some unneeded changes
  Don't use env vars in all config examples
  add more trailing comma on last array element symfony#9493
  add trailing comma on last array element symfony#9493
  codestyle
  add documentation for external parameters and pdo host parameter
javiereguiluz added a commit to javiereguiluz/symfony-docs that referenced this pull request Jul 12, 2018
* 4.0:
  Remove some unneeded changes
  Don't use env vars in all config examples
  add more trailing comma on last array element symfony#9493
  add trailing comma on last array element symfony#9493
  codestyle
  add documentation for external parameters and pdo host parameter
javiereguiluz added a commit to javiereguiluz/symfony-docs that referenced this pull request Jul 12, 2018
* 4.1:
  Remove some unneeded changes
  Don't use env vars in all config examples
  add more trailing comma on last array element symfony#9493
  add trailing comma on last array element symfony#9493
  codestyle
  add documentation for external parameters and pdo host parameter
Guikingone pushed a commit to Guikingone/symfony-docs that referenced this pull request Feb 12, 2019
Guikingone pushed a commit to Guikingone/symfony-docs that referenced this pull request Feb 12, 2019
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.

5 participants