sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Symfony 5 compatibility #5788

Closed mouad-mahfoud closed 4 years ago

mouad-mahfoud commented 4 years ago

I am trying to install sonata admin bundle in a fresh Symfony 5 installation but I get this error : Problem 1

VincentLanglet commented 4 years ago

sorry my english is not perfect. I think addition of support symfony 5.0 will result in a compatible

The support of symfony 5.0 is still not fully added. We are still working on it. Some of the packages provided by sonata are compatible ; but not all. Since the admin bundle is using a lot of them, it will certainly be the last bundle compatible with symfony 5.

If you want to make some PR to help us, don't hesitate ;)

MichaelPerlbach commented 4 years ago

Any news on that matter?

VincentLanglet commented 4 years ago

We're working on it, but that's not easy. You can help us if you want.

MichaelPerlbach commented 4 years ago

I would be glad if I could be a useful help for you. Thing is, I am relatively new to Symfony - and I know nothing about the inner workings of Sonata Admin. But if you have tasks I might be able to do within these boundary conditions tell me!

wbloszyk commented 4 years ago

@MichaelPerlbach I think you can extract actions from CRUDController.

@VincentLanglet @core23 WDYT?

VincentLanglet commented 4 years ago

Refactoring is always nice, but I don't see why this would help for Symfony 5 ?

@greg0ire Gave an exemple with sonata-exporter here https://github.com/sonata-project/SonataAdminBundle/issues/5788#issuecomment-599190473

And then ask to do the same for other bundle https://github.com/sonata-project/SonataAdminBundle/issues/5788#issuecomment-600484369.

If we want sonataAdmin to support Symfony 5, we needs that every sonataAdmin dependencies support Symfony 5. So start with the dependencies.

wbloszyk commented 4 years ago

We can't support symfony5 when we use controller.

VincentLanglet commented 4 years ago

Ok, you meant extending AbstractController instead

wbloszyk commented 4 years ago

Ok, you meant extending AbstractController instead

This too. I mean more split CRUDController to improve extending CRUD actions by user. We should not keep do big controller in next major. We probably can't add support for symfony5 in sonata 3.

VincentLanglet commented 4 years ago

I mean more split CRUDController to improve extending CRUD actions by user. We should not keep do big controller in next major.

I disagree. Splitting the CRUDController is not needed for Symfony 5.

What are the minimal changes needed to be symfony 5 compatible, this is only what we should focus on.

jorrit commented 4 years ago

If we want sonataAdmin to support Symfony 5, we needs that every sonataAdmin dependencies support Symfony 5. So start with the dependencies.

Is there an up to date overview of the specific changes that are needed?

jorrit commented 4 years ago

Just to clarify: is it a goal to have Symfony 5 support in Sonata 3? Or is it a goal for Sonata 4?

VincentLanglet commented 4 years ago

@wbloszyk Will be the best to answer this 😅

wbloszyk commented 4 years ago

@VincentLanglet https://github.com/sonata-project/SonataBlockBundle/issues/700#issuecomment-643262523

wbloszyk commented 4 years ago

@jorrit In SonataBlockBundle add support for:

In SonataIntlBundle add support for:

In SonataAdminBundle add support for:

This change will be probably enought to add this support in this bundles.

jorrit commented 4 years ago

@wbloszyk : Do you mean version 3 of those three modules? Because SonataBlockBundle already has SF5 support but only in version 4.

wbloszyk commented 4 years ago

Sonata 3 using BlockBundle 3. Add support in Sonata 3 for BlockBundle will be awsome too but much harder.

jorrit commented 4 years ago

So if I understand it correctly, BlockBundle 3 also has to support Symfony 5?

wbloszyk commented 4 years ago

All require dependencies have to support symfony 5 too.

jorrit commented 4 years ago

On https://github.com/sonata-project/SonataAdminBundle/pull/5948#issuecomment-599140668 it was determined that SF 5 compatibility in Sonata 3 is not possible.

neimheadh commented 4 years ago

Hello everyone.

I just forked the project to work on the Symfony 5 compatibility. I don't know a lot about the Sonata admin bundle background, but for the moment I just changed symfony dependencies to "^5.1", and the composer install worked. Of course I have some inheritance errors, I'm working on it, but it seems that the "sonata-project/admin-bundle" sub-dependencies has no problem with SF 5.1.

As I see with the @jorrit comment, you seem to have blocking problems with knp-menus but.. The issue is closed so maybe not. Idk...

Do you have a clear view of SF5-compatibility progress on your side?

jorrit commented 4 years ago

@neimheadh : The issue was closed for the master branch which will one day be Sonata Admin v4 but I am trying to get a statement on whether SF5 support will ever be available for Sonata Admin v3.

VincentLanglet commented 4 years ago

On #5948 (comment) it was determined that SF 5 compatibility in Sonata 3 is not possible.

Only if you can avoid this BC-break.

We try to finish the v4, but it's not easy.

neimheadh commented 4 years ago

@neimheadh : The issue was closed for the master branch which will one day be Sonata Admin v4 but I am trying to get a statement on whether SF5 support will ever be available for Sonata Admin v3.

Yeah I see. Indeed I'm working on master branch. Are you interested I push my change on master when I'll be able to use Sonata (dev-master version) on my project?

VincentLanglet commented 4 years ago

We are really interested by any kind of PR to help us to finish the v4 or to add the Symfony 5 (or twig 3) support.

The current dev-master branch can't be used. And that's a big issue, because we can't test manually any PR on the master branch.

The first step would be to fix this and allow to use both the SonataAdmin and SonataDoctrineORMAdmin dev-master branch together. I think it's on the @wbloszyk plans, isn't it ?

neimheadh commented 4 years ago

Yes, I also try to make SonataDoctrineORMAdmin dev-master work on SF.5.1. Btw I see that @SonataAdmin/standard_layout.html.twig needs @SonataCore/FlashMessage/render.html.twig and @SonataTwig/FlashMessage/render.html.twig.

Is it a reason for sonata-project/admin-bundle not having sonata-project/core-bundle & sonata-project/twig-extensions dependencies?

VincentLanglet commented 4 years ago

Yes, I also try to make SonataDoctrineORMAdmin dev-master work on SF.5.1. Btw I see that @SonataAdmin/standard_layout.html.twig needs @SonataCore/FlashMessage/render.html.twig and @SonataTwig/FlashMessage/render.html.twig.

Is it a reason for sonata-project/admin-bundle not having sonata-project/core-bundle & sonata-project/twig-extensions dependencies?

It does have twig-extension dependency. A recent PR removed the Core dependency, I think, by the syntax, it requires @SonataCore/FlashMessage/render.html.twig OR @SonataTwig/FlashMessage/render.html.twig.

wbloszyk commented 4 years ago

Yes, I'm working on it. @SonataAdmin/standard_layout.html.twig needs @SonataCore/FlashMessage/render.html.twig OR @SonataTwig/FlashMessage/render.html.twig.

Now I'm working on replace CoreBundle by form- and twig- extensions 0.x. Then upgrade it to extensions 1.x. https://github.com/sonata-project/dev-kit/issues/697

To finish it i need improve FlashManager: https://github.com/sonata-project/twig-extensions/issues/89 https://github.com/sonata-project/twig-extensions/pull/90

At the end support the same BlockBundle version is require to allow use Sonata 3 and Sonata 4 together.

neimheadh commented 4 years ago

Yep my mistake, it is @SonataCore/FlashMessage/render.html.twig OR @SonataTwig/FlashMessage/render.html.twig.

So if I got it well @wbloszyk, the CoreBundle will be deprecated in the future in favor of SonataTwig (and some others)?

wbloszyk commented 4 years ago

Correct: https://github.com/sonata-project/SonataCoreBundle#warning-this-bundle-is-deprecated

neimheadh commented 4 years ago

I finally have a working instance on SF5.1. Here what I had to do :

https://github.com/sonata-project/SonataAdminBundle/compare/master...neimheadh:master

https://github.com/sonata-project/SonataDoctrineORMAdminBundle/compare/master...neimheadh:master

And I'm good, with an empty Sonata project. I don't want to do the PR now as my dependencies changes are a little bit extreme, with no test for the moment of inheritance changes on SF4 and SF5.0. And I also don't know what are your workflow so... Feel free to tell me how to make my PR on your project if you're interested.

neimheadh commented 4 years ago

Hello, it's me again. Again a little change on AdminBundle fixing exception when I create a new admin on SF5.1 - just changed Symfony\Component\Translation\TranslatorInterface dependency to Symfony\Contracts\Translation\TranslatorInterface. Also fixed dependencies for CRUDController and FieldDescription: https://github.com/sonata-project/SonataAdminBundle/compare/master...neimheadh:master

I also allowed null Help one base fields, I don't know if it should be mandatory, but if I follow documentation, it shouldn't be.

wbloszyk commented 4 years ago

Close this issue in favor for https://github.com/sonata-project/SonataAdminBundle/issues/6365