Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

going to build a php MVC, what naming conventions do i need to be aware of?

I'm pretty new to OO PHP, however i get how it all works and am ready to start building an MVC for a big site i'm working on. I know it isnt necessary written that you must do it like this but there's gotta be some normal practises....

class names - camelcase? underscores?

class files - same as class?

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

any other things i should be aware of before i embark?

like image 524
Haroldo Avatar asked Apr 27 '10 20:04

Haroldo


4 Answers

It doesn't really matter how you name things as long as you are consistent.

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

  • Zend Framework Coding Standard for PHP
  • PEAR Coding Standards
  • Horde Coding Standards
like image 145
Yacoby Avatar answered Oct 23 '22 19:10

Yacoby


http://framework.zend.com/manual/en/coding-standard.naming-conventions.html Should be your bible as a PHP developer.

like image 34
Mikushi Avatar answered Oct 23 '22 19:10

Mikushi


Class constants are generally all uppercase, Class names are generally like java with capital first letters SomeClassName

Beyond that, I guess it depends who you ask

like image 23
Mitch Dempsey Avatar answered Oct 23 '22 19:10

Mitch Dempsey


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

It's not at all what you asked, but do consider looking at one of the literally dozens and dozens of existing MVC-style PHP frameworks. You can save yourself a lot of time and generally get better quality if you use a solid existing framework.

like image 28
Funkatron Avatar answered Oct 23 '22 20:10

Funkatron