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

Add example configuration using url instead of multiple parameters #24

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,37 @@ doctrine:
x_reconnect_attempts: 3
```

An example of configuration on Symfony 3/4 projects using url instead of separate parameters.

#### Warning:
The url **MUST** be schemaless. An `InvalidArgumentException` will be thrown otherwise.
```
Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection needs a driver that implements ServerGoneAwayExceptionsAwareInterface
```

```yaml
# Doctrine example Configuration
parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
Copy link
Member

Choose a reason for hiding this comment

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

This is wrong. If the cache warmup triggers a DB connection in Doctrine it's not this lib's fault, but it's due to the fact that you didn't specify a DB version/charset in the connection, so Doctrine is forced to connect to it to obtain those.

Copy link
Member

Choose a reason for hiding this comment

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

@samvdb
may you change the PR accordingly with @Jean85 suggestion?
should be really fast, then we'll merge this.
thanks,

Copy link
Member

Choose a reason for hiding this comment

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

@samvdb any update on this?

# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): '//user:example@localhost:3306/db-name?serverVersion=5.6&charset=utf8mb4'

doctrine:
dbal:
default_connection: %connection_name%
connections:
%connection_name%:
# With Symfony 3.3, remove the `resolve:` prefix
url: '%env(DATABASE_URL)%'
wrapper_class: 'Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection'
driver_class: 'Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Driver\PDOMySql\Driver'
options:
x_reconnect_attempts: 3

```

An example of configuration on Zend Framework 2/3 projects:

```php
Expand Down