Practice to be followed while coding object oriented PHP

2 views
Skip to first unread message

PRASANT KUMAR SUMAN

unread,
Mar 5, 2013, 12:06:23 AM3/5/13
to weeke...@googlegroups.com
Dear sir and all,

Can you (All) please suggest best practice method to be followed while programming for Object Oriented PHP .. i am getting meshed 
Some common conventions and coding practice so that I can adhere it in future ..for better practice ...

vikas dwivedi

unread,
Mar 5, 2013, 12:35:45 AM3/5/13
to php
Hello Prashant,

First I would like to suggest please use any framework, you will get most of the functionality in build.

In Controller :-
Always create one parent class for your site and this class extends the Framework Controller Class,instead of extending that Framework class(Zend_Controller_Action) in every controller. 

class SiteController extends Zend_Controller_Action{}

class HelloController extends SiteController {}
class UserController extends SiteController {}
class CategoryController extends SiteController {}

Now, you can put all common code of your site in SiteController , 
for ex: if you need to send mail to users the put sendMail() in SiteController so that every controller can access the same.

In Model :-
Same as Controller make parent class of each model.
create common methods like fetchAll(), delete(), deleteById(), getMaxId(), fetchById() ......
in parent model, in that way your models are almost empty..

Means they contain only dedicated methods associated with that particular Model.  
-------------------------------------------------------- 

2. Functions used for ajax call need to start with ajax or any prefix so that you can easily figure out all the ajax methods in any controller.

3. You should follow Zend Naming Convention while you code.




regards !
vikas dwivedi 


--
Manage your settings from http://groups.google.com/groups/mysubs?pli=1
---
You received this message because you are subscribed to the Google Groups "Weekend php classes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weekendphp+...@googlegroups.com.
To post to this group, send email to weeke...@googlegroups.com.
Visit this group at http://groups.google.com/group/weekendphp?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

PRASANT KUMAR SUMAN

unread,
Mar 5, 2013, 1:57:41 AM3/5/13
to weeke...@googlegroups.com
Thanks sir...
These suggestions are future pillars for our coding

ℙґα﹩@η☂ Ḳüღαґ $üмαη
www.facebook.com/PKSUMAN
Mob:- 08010173356


suraj gurung

unread,
Mar 5, 2013, 8:03:50 AM3/5/13
to weeke...@googlegroups.com
yes sir is it usefull for all the beginners thanks sir for showing the path..
Reply all
Reply to author
Forward
0 new messages