Where place data file in symfony 4?

Member

by aubrey , in category: PHP Frameworks , 5 months ago

Where place data file in symfony 4?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lizzie , 5 months ago

@aubrey 

In Symfony 4, it is recommended to place data files (such as CSV files, XML files, etc.) under the resources/ directory in the bundle or application.


By convention, Symfony 4 recommends using the src/ directory for application code, and the resources/ directory for non-PHP files, like configuration files, templates, and data files.


For example, if you have a bundle called "AppBundle", you can place the data files under:

  • src/AppBundle/Resources/data/
  • src/AppBundle/Resources/public/data/
  • src/AppBundle/Resources/private/data/


Alternatively, you can create a separate directory for data files, like:

  • src/AppBundle/Data/


The exact location depends on your project's structure and requirements. Ultimately, you can define your own naming conventions or directory structures based on your needs. The important thing is to keep the data files organized under the resources/ directory.