Architecture That Grows with Your Project
One of the most common challenges in PHP application development is proper code organization. Where should presenters go? Where should individual classes be located? And how to ensure the project structure grows naturally with its development?
Nette documentation brings a comprehensive guide to directory structure that offers answers to all these questions.
The quality of code organization significantly affects its readability. At
first glance at a new project, you should quickly understand its purpose. Take a
look at this app/Model/
directory:
app/Model/
├── Services/
├── Repositories/
└── Entities/
What does this structure tell you about the application? Almost nothing. Compare with this alternative:
app/Model/
├── Cart/
├── Payment/
├── Order/
└── Product/
It's immediately clear that this is an e-commerce application. That's the power of domain-oriented structure that the document presents.
The guide also shows how to naturally evolve the structure as your project grows. Whether you're starting a new project or want to improve an existing application, you'll find principles for making informed decisions about code organization.
Read the Application Directory Structure chapter in Nette documentation and blogpost Elegant Presenter Structuring.
Further reading
- Elegant Presenter Structuring
- How to pass app directory paths to services
- Write Safer Code with the New Nette Database Documentation
- Aliases: A New Feature in Application Navigation
- Nette Vite – using Nette with Vite for rapid local development
- One line in configuration will speed up your Nette application. How is that possible?
Comments
When I saw the title I thought that the www directory will be named public or we will use var/log and var/cache instead of temp and log 😁 but this is also a big step forward, I made same mistake 8 years ago and it was unbearable with what big Repositories/Services directories, and a lot of frameworks (even in different programming languages) are suggesting it, and maybe more than 1/2 of PHP projects are still using it.
Sign in to submit a comment