-
Notifications
You must be signed in to change notification settings - Fork 0
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
Convert PHP Array Config to PHP ConfigBuilder #4
Comments
I had the same thought... and also not sure if it's possible. Well, those config builders are built from the config tree/Configuration classes... so in theory it might be possible. But these seems important. If we're going to allow PHP config, I think the config builders need to be used from day 1 or never at all. Switching to it later would be a second nightmare of updating docs, getting people to migrate again and trying to get |
Understand your point, I added it also to the release milestone. I already had a quick chat with @Nyholm about the ConfigBuilders as I think he knows most about them. He already mention that the yaml has some shortcuts, if he got some time he will add his thoughts about it. |
There is still a long way in front of us but already created a prototype to convert PHP Array Configs to ConfigBuilder. First results: <?php
declare(strict_types=1);
+use Symfony\Config\FrameworkConfig;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
-return static function (ContainerConfigurator $containerConfigurator): void {
- $containerConfigurator->extension('framework', [
- 'session' => [
- 'handler_id' => null,
- 'cookie_secure' => 'auto',
- 'cookie_samesite' => 'lax',
- 'storage_factory_id' => 'session.storage.factory.native',
- ],
- ]);
+return static function (FrameworkConfig $frameworkConfig): void {
+ $frameworkConfig->session()->handlerId(null)->cookieSecure('auto')->cookieSamesite('lax')->storageFactoryId('session.storage.factory.native');
if ($containerConfigurator->env() === 'test') {
- $containerConfigurator->extension('framework', [
- 'session' => [
- 'storage_factory_id' => 'session.storage.factory.mock_file',
- ],
- ]);
+ $frameworkConfig->session()->storageFactoryId('session.storage.factory.mock_file');
}
}; Test Repo: https://github.com/alexander-schranz/prototype-config-builder-refractor Currently it is very abstract and is not aware of the ConfigBuilder class. I could not yet find out how to load the ConfigBuilder classes as they seems not registered via the autoloader, which will be required so I can find the correct methods which I need to call. |
That's impressive! Even Tobias, who created the I'm not sure about the autoloader part... I do know these classes are compiled into the cache, so they must be required some "other" way by Symfony itself. Do you think this approach could actually work? There are a lot of different config and config builders. I want it to work - but I know it's complex! |
@Nyholm could already help me with the autoloader. There is some generator which is currently handling this. The config transformer is currently very dumb and not aware of the edge cases. But we really has the advantages that we can test the converter against all currently provided Recipes. I will mostly spend the next time working on a
This way and running it against all already existing packages should help us find all edge cases :) |
Since Symfony 5.3 there exist a new way of configuring packages. The
config builders
:https://symfony.com/blog/new-in-symfony-5-3-config-builder-classes
It would be great as we are currently having done the step from
yaml
tophp
configs. To do the next step from PHP array configs to PHP config builder configs.Not sure how easy possible without knowing the
Builder
class and only thearray
this is even possible.The text was updated successfully, but these errors were encountered: