Proper organization of PHP code for CRUD application?
What is the most efficient way of organizing PHP code for a CRUD application? What are the well-known nam开发者_如何转开发ing conventions? I have a class and its getters and setters just seem to be SQL queries. Is this correct, or how am I supposed to organize it?
You should have a look at DomainModels and DataMappers. In general, I recommend the Zend Framework and its Quickstart Tutorial, as it teaches these two very relevant patterns in a few minutes by example. You do not need to switch to Zend Framework afterwards, but it is good learning material.
Use the MVC pattern. Then you allready have files in the folders:
models
views
controllers
inside this folders I would recommend not to use prefixes or sufixes because the files are already in such an folder. But extend all controller files and model files from one main class!
Maybe you want to download and study a example project made in CakePHP framework which is very well structured and uses CRUD as well!
精彩评论