symfony / recipes-contrib

Symfony Contrib Recipes Repositories

Home Page:https://github.com/symfony/recipes-contrib/blob/flex/main/RECIPES.md

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bref Symfony Bridge recipe

ker0x opened this issue · comments

Hello

After some discussion with @mnapoli and @t-richard, we would like to propose a recipe for brefphp/symfony-bridge.

Currently the recipe will focus on doing 3 things:

  • Adding the .serverless folder to .gitignore
  • Creating a serverless.yml already configured for a simple Symfony application
  • Updating src/Kernel.php with the necessary changes

However, before opening a PR we have some questions in suspend.

The library is not a Symfony bundle, so we were wondering if a recipe would be accepted for it?

Next, to work the bridge has to replace the default Kernel.php created by Symfony with a new one extended it to override the cache and logs directories. Is it something a recipe is allowed to do or is it only permitted by offcial recipes (or totally forbidden) ?

Finally, the recipe will create a serverless.yml configuration file at the root of the project. Does this file should be store on the library side or recipe side?

We accept recipes for any packages available on Packagist (we do have plenty on non-bundles already).

Replacing an existing file is not an option as it would make debugging/upgrading/... much harder. We should find another way. Maybe the new runtime component can help here?

Generating files is one of the things a recipe can do, so I don't any issue here.

@fabpot thank you for the answer!

Replacing an existing file is not an option as it would make debugging/upgrading/... much harder. We should find another way. Maybe the new runtime component can help here?

Nyholm is working hard on that, the runtime component could be useful in some ways, but AFAIK not directly for this problem.

On Lambda, logs & cache need to be moved elsewhere (because the filesystem is read-only except for /tmp). The only way to do that is by editing Kernel.php (unless there's another way?).

Worst case scenario: we ask the user to do the change manually, which isn't the end of the world. But I'd love to know if there's an alternative that could be automated.

What about adding a ServerlessKernel.php file next to the Kernel and tell the user to change one line in index.php ?

@OskarStark that is the same amount of changes as telling the user to extend Bref's modified Kernel.

What about adding a ServerlessKernel.php file next to the Kernel and tell the user to change one line in index.php ?

IMHO it's just moving the manual action to another place.

The current documented way with the Kernel is below and moving to index.php would be similar.

// src/Kernel.php

namespace App;

+ use Bref\SymfonyBridge\BrefKernel;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;

- class Kernel extends BaseKernel
+ class Kernel extends BrefKernel
{
    // ...

Ok I thought it would need more adjustments 👍🏻

Thanks everyone for the input ! @ker0x I think we should start simple

  1. copy-from-recipe for the serverless.yaml
  2. add .serverless in gitignore
  3. add a post-install.txt to explain what to do with the kernel

Once done, we could see what more can be done with the Kernel.

What do you think ?

@t-richard sounds good, though I wouldn't put any documentation file in the project: readers should be following the documentation already so we can explain the last step there.

@t-richard it sounds good to me too, I will start to work on it this week probably !

@mnapoli At first the post-install.txt file will only show a link to the documentation (which will need to be updated though). We can always improve it later

@ker0x I'd rather not have a documentation file inserted into the project, that doesn't correspond to any practice found in other open-source projects. Users are already following the documentation, we can instruct them on what to do inside the documentation.

I'm closing the issue as #1129 has been merged. Thanks to everyone for your advices and reviews ❤️

Thank you @ker0x!