Why does the Symfony crud generated template file be placed in the app directory?

Source: Internet
Author: User
I want to put it in the SRC directory.

Reply content:

I want to put it in the SRC directory.

About the location of template files

The template file is placed in the SRC directory for only one reason: your template file belongs to "reusable bundle (Reusable bundle)"!

If this is the case, such as the Bundle name is Acmeblogbundle, then the location of the template file is usually "Src/acme/bundle/blogbundle/resources/views". But the premise of this is that your bundles are reusable and can be used directly on other projects.

If this is not the case (usually not, unless you are developing a third-party bundle, such as Fosuserbundle), then the template file is placed under "App/resource/views" Conforms to Symfony's practice (Convention) and recommended .

About Bundles

Best Practice

Create One bundle called Appbundle for your application logic

As above (from Symfony official documents), Symfony's official best practices recommend an app that only needs to create a bundle(Appbundle) is enough. In fact, when you create an app with the Symfony command, the bundle is already built.

How can I tell if I need to create a bundle?

    1. When you have multiple projects that can use the same application logic (Domain logic), you can abstract this set of application logic as a separate bundle of bundles.

    2. The application logic of the independent bundle can not rely on other bundles, otherwise it is not a separate bundle.

    3. When you create a standalone (reusable) bundle, nature, including its associated templates, configuration files, and so on, can be placed under its own file structure.

Refer to the file structure of the standalone (reusable) bundle as follows (from Symfony official website document)


  
   
    
   /├─ AcmeBlogBundle.php├─ Controller/├─ README.md├─ LICENSE├─ Resources/│   ├─ config/│   ├─ doc/│   │  └─ index.rst│   ├─ translations/│   ├─ views/│   └─ public/└─ Tests/
  
   

Finally, attach the link URL of symfony about best practice

Symfony Best Practices
Best Practices for Reusable Bundles

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.