doute7910 2018-02-08 23:19
浏览 81
已采纳

Symfony4代码(目录)结构组织

How should I organise the directory/code structure with Symfony4?
I started with
Controller\*BName*\*Fname*\...
Entity\*Fname*\...
Repository\*Fname*\...
Form\*BName*\*Fname*\...
Services\*Fname*\...

Before Symfony4, my structure was
*BName\Controller\*Fname*\...
*BName\Entity\*Fname*\...
... What is right way?

  • 写回答

1条回答 默认 最新

  • dt20081409 2018-02-09 00:07
    关注

    General structure:

    • Web files under public/
    • Temporary files under var/
    • Source Code under src/
    • Configuration under config/
    • Templates under templates/
    • Tests under tests/

    In Symfony versions prior to 4.0, it was recommended to organize your own application code using bundles. This is no longer recommended and bundles should only be used to share code and features between multiple applications.

    You don't have any Bundle in your source code now.

    You can have

    --src/
    ----Controller/
    ------Admin/
    ------ProductController.php
    ----Entity/
    ----Form/
    ----Repository/
    

    I would not recommend you to do a service folder as everything is/can be a service. Instead, you should group them according to their responsibilities

    ----Provider/
    ------UserProvider.php
    ----Validator/
    ----Manager/
    ----Generator/
    ------CsvGenerator.php
    ----Mailer/
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部