egidra
egidra

Reputation: 923

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 naming 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?

Upvotes: 1

Views: 704

Answers (2)

powtac
powtac

Reputation: 41050

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!

Upvotes: 1

Lars
Lars

Reputation: 5799

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.

Upvotes: 1

Related Questions