Skip to content

Conversation

@alexandre-daubois
Copy link
Member

@alexandre-daubois alexandre-daubois commented Oct 2, 2024

Q A
Branch? 7.2
Bug fix? no
New feature? yes
Deprecations? no
Issues -
License MIT

We are introducing the clock component in a project. Because of legacy reasons, dates are stored using the Europe/Paris timezone instead of using UTC. Because we'd like to use the clock service and the ClockAwareTrait, it would be nice to configure the timezone to use right in the framework configuration, under a new option called clock.default_timezone:

framework:
    clock:
        default_timezone: Europe/Paris

This adds more flexibility to developers to configure the default timezone to use. Even if the clock gets a default timezone using date_default_timezone_get(), having the possibility to set this option would remove some magic. More than that, it makes the clock service consistent across different PHP installation that may have any value in their php.ini.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

To challenge this: not setting the ini option while setting the config option might create discrepancies between parts that use the time without getting through the clock component. Not sure this is a win. Having better control of ini settings might be preferable. When using Platform.sh for example, you can commit a php.ini file at the root of your app. That's a better alternative to me.

}

try {
return new \DateTimeZone($v);
Copy link
Member

Choose a reason for hiding this comment

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

this validation logic prevents using env vars for configuring the option

@javiereguiluz javiereguiluz added the ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" label Oct 3, 2024
@alexandre-daubois
Copy link
Member Author

I understand, maybe this option could come with a warning in the ->info() part about it? My use case is that we have several (legacy or not) project running with the same php.ini in our team. This option would allow to configure a timezone at the framework level only in the dev env, for example. This way, we don't have to touch the php.ini file that works great with the other projects when running multiple projects on the same machine.

However, I understand your point of view about omitting the option in php.ini. This could be indicated in the explanation of the option?

@nicolas-grekas
Copy link
Member

I'd say you need to improve your dev stack: eg if you use symfony serve, php.ini in the root of the app is also loaded. Just use it :)

@alexandre-daubois
Copy link
Member Author

I wasn't aware of this feature. Indeed, that's way better. Let's close then, thanks!

@alexandre-daubois
Copy link
Member Author

Thanks for this feedback @ro0NL, would this PR solve your issue? Could you maybe elaborate a bit on how this would help you if possible? I'd be happy to reopen if relevant 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature FrameworkBundle ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" Status: Reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants