Symfony 6 & Custom Bundle - tutorial how to create (best practices)

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ย. 2024

ความคิดเห็น • 13

  • @quanchi88
    @quanchi88 11 หลายเดือนก่อน +1

    Thanks. This helped me to finally make my first bundle work

    • @tanyawebdev
      @tanyawebdev  11 หลายเดือนก่อน

      (⌒‿⌒) I'm glad the video was useful to you!

  • @project-lu3qv
    @project-lu3qv ปีที่แล้ว

    Great tutorial thanks

  • @evgeniichornyi678
    @evgeniichornyi678 ปีที่แล้ว

    Thanks, great video

  • @AlexD-lc2nx
    @AlexD-lc2nx ปีที่แล้ว +1

    Good tutorial format but there are no entities, bundle config building etc.

  • @aliakbarmohajeruni3628
    @aliakbarmohajeruni3628 8 หลายเดือนก่อน

    Help me
    Use captach symfony 7 but notfound or is old package
    Suggest captach?

  • @scheidegg
    @scheidegg หลายเดือนก่อน

    No repo?

  • @杨志-n6z
    @杨志-n6z ปีที่แล้ว

    great tutorial,how to use bundle make CRUD?

  • @damienollivier5541
    @damienollivier5541 9 หลายเดือนก่อน

    Great tutorial thank you. Do you know if there is a way to automatically create/import the route file into the app route folder when the bundle is installed ?

    • @tanyawebdev
      @tanyawebdev  9 หลายเดือนก่อน +2

      Yes, there are several ways to automatically create or import a route file into the app route folder when installing a Symfony bundle:
      1. Using the "KernelEvents::BUNDLE_POST_INSTALL_EVENT" event
      - Create a listener for the KernelEvents::BUNDLE_POST_INSTALL_EVENT event.
      - In the event listener, check if the installed bundle is your custom bundle.
      - If it is, get the path to your bundle's route file.
      - Copy or import the route file into the app route folder.
      - You can use Symfony's built-in functions, such as file_put_contents() or $router->import(), to perform the copying or importing.
      2. Using the Symfony Flex autoloading system
      - Create a composer.json file in your bundle and specify the autoload.psr-4 section with your bundle's namespace.
      - Place the route file in the folder specified in the autoload.psr-4 section.
      - Symfony Flex will automatically load the route file when the bundle is installed.
      - Make sure that the route file uses absolute paths for the routes so that they are registered correctly.
      3. Using a Symfony Console command
      - Create a Symfony Console command that performs the copying or importing of the route file.
      - Add the command to the scripts section of your bundle's composer.json file.
      - Run the composer run command after installing the bundle to launch the script and import the routes.
      4. Using the "BundleImporter" package
      - Install the "BundleImporter" package with Composer.
      - Create a configuration file for the package, specifying the path to your bundle's route file and the app route folder.
      - When the bundle is installed, the "BundleImporter" package will automatically import the route file.
      ---
      Which method to choose depends on your preferences and project requirements.
      - Method 1 is the most flexible but requires writing an event listener.
      - Method 2 is simpler to implement but requires using Symfony Flex and absolute paths in the route file.
      - Method 3 is convenient for creating separate commands for managing routes but requires additional code.
      - Method 4 uses a third-party package, which may be simpler but adds a dependency.

    • @damienollivier5541
      @damienollivier5541 9 หลายเดือนก่อน +1

      @@tanyawebdev thank you for your answer. I'm gonna try all the methods just for fun but I think I'm gonna use the first one, I find it more elegant and it seems to suit the needs of my project. thank you for your hard work your chanel Is a gold mine.

    • @tanyawebdev
      @tanyawebdev  9 หลายเดือนก่อน

      @@damienollivier5541 Thank you for your kind words, it inspires me to move on! :)