Going to build php MVC, what naming conventions do I need to know?

I am new to OO PHP, however I understand how it all works, and I am ready to start creating MVC for the large site I'm working on. I know that it’s not necessary to write that you should do it this way, but there should be some normal practices ....

class names - camelcase? emphasizes?

class files - same as class?

url / post / get controll name - router.php?

any other things i should know about before i get started?

+6
php model-view-controller
source share
6 answers

It doesn't really matter how you call things until you are consistent.

If you are interested in taking a look at coding standards:

+9
source share
+1
source share

Class constants, as a rule, have all uppercase letters, class names are usually similar to java with the letters of the first letter SomeClassName

Other than that, I think it depends on who you ask.

+1
source share

Try the following: https://stackoverflow.com/questions/332831/php-best-practices-for-naming-conventions/332854#332854

This is not at all what you requested, but consider looking at one of the literally dozens and dozens of existing MVC-style PHP frameworks. You can save a lot of time and, as a rule, get the best quality if you use a solid existing infrastructure.

+1
source share

In terms of MVC logic, at least separate your control and presentation. I work with Wordpress, which looks very awful in places, especially on the admin side. For my part, I have a controller that checks $ _REQUEST, making changes to the data, interacting with the database, and then create the appropriate view class.

+1
source share

Preferred directory structure: My / Class.php

ClassNames: My_Class

If you use the modular MVC framework, make sure you have the namespace included in your bootstrap.php [this is specific to the Zend Framework, but I suppose there should be something similar for other mvc frameworks).

what else ... name names - by default dropDownAction () becomes drop-down.phtml in Zend Views.

+1
source share

All Articles