Project structure for PHP

后端 未结 5 1169
被撕碎了的回忆
被撕碎了的回忆 2021-01-30 11:39

I am new to PHP and want to know the directory structure for the php projects. I have experience in Java and in java we have src contains java source files, WEB-INF contains lib

5条回答
  •  北荒
    北荒 (楼主)
    2021-01-30 12:11

    I tend to use a Feature-based folder structure for my backend projects. Every feature-folder has his own controller, manager and routes file. This works well for api-backends. It looks in a way like https://blog.nikolaposa.in.rs/2017/01/16/on-structuring-php-projects/

    For example, we have a Customer feature with a CustomerController, CustomerRepository, CustomerRoutes,..

    My folder structure looks like this:

    - build/
    -- phpdox.xml
    -- phpmd.xml
    -- phpunit.dist.xml
    - config/
    - public/
    -- .htaccess
    -- index.php
    -- assets/
    - src/
    -- Customer/
    --- CustomerController.php
    --- CustomerRepository.php
    --- Customer.php
    --- customer.routes.php
    - tests/
    - vendor/
    composer.json
    .gitignore
    

提交回复
热议问题