Directory structure for a PHP website using composer, gulp and Travis Directory structure for a PHP website using composer, gulp and Travis php php

Directory structure for a PHP website using composer, gulp and Travis


I agree with the comment from Korri above, in that you could benefit from taking inspiration from existing frameworks.

Personally, this sort of directory structure feels right, to me.

.|-- composer.json|-- gulpfile.js|-- package.json|-- changelog.md|-- readme.md|-- /src (This is the API code that *I'm* responsible for, and that I *own*.).|   |-- /app|   |   |-- /controllers|   |   |-- /models|   |   `-- <other_framework_stuff>|   /public (Keeping this outside of the src dir, means that you can give this to your front-end devs without needing to have the entire codebase).|   |   |-- /styles|   |   |-- /images|   |   |-- /js|   /config (Put all configuration files outside of the src scope, so you can keep it outside of source control)|   /build (CI build related configuration)|   |   |--phpcs.xml|   |   |--phpdocx.xml|-- /tests (separating out your tests in this way can help you run tests separately, more easily)|   |   |--acceptance|   |   |--integration|   |   |--unit|-- /vendor (Depenedencies installed via Composer)

Really, there's no community driven correct answer to your question. The correct answer is specific to your business, the team you work in, and the project itself.

I'd never put the /vendor directory within your /src directory - because you don't own it. You're not responsible for the changes to the code within your project's dependencies, so it should be left in its own scope outside of your projects walls.

With PSR-4 autoloading, it really doesn't matter too much about your directory structure, it can be changed easily at any time, with no impact on your code. So, experiment and see what feels right for you.