Where should I put my own PHP classes?

I realize that I can put them anywhere, but what is a good common practice? /protected/src ?

hello, u can put ur classes inside the component folder(good practice),

or alternatively u can create a folder n put them but u have to add the directory path in ur main config file so that they will be autoloaded.

eg u create a folder called myClasses

edit the main.php in the config folder

// autoloading model and component classes






great, thanks

IMHO, i think you shouldn’t drop the MVC concept in solving your problem. I think if your class would be close enought to model, then put them under model/yoursubfolder, but if the class is for instant a collection of repetitive used function then you might put them on the component.

There are no many answers, because there is no the only true answer to your question. We can tell our opinions (I’m sure they will be different), but I wouldn’t count a most-common opinion a “good practice”. The best solution here is the one which is the most comfortable for you.

I usually put my own stuff in components, and other peoples stuff in extensions. ;)

I do have a ‘helper’ directory, though…

And plan to create a ‘widgets’ directory too…

But that’s me.

As Andy said, that’s really a matter of taste (or lack thereof). ;)