Skip to content

how to add classes to a Zend Framework project

September 26, 2010

You always have classes written from before that you want to reuse in your projects, Zend has made it a bit harder to get them running but when you get your classes, to work, everything goes very well.

You might have noticed when you add a new class, your IDE may recognize it, but when you run your project on apache it is not recognized.

There are a few things you need to do in order to have your classes run under your project.

1- File structure and naming

If your class name is “Class_DB_Repair” then it should be stored in a file named Repair.php in “Class\DB\” folder.

2- Put your “Class” folder or any other folder that is the root of all your classes somewhere nice, I usually put them all in “library”.

3-Add this to your public/index.php

$Zend_Loader_Autoloader = Zend_Loader_Autoloader::getInstance();

4-I’m not sure if this is necessary or not but you can add this to application.ini too

includePaths.Ycode = APPLICATION_PATH “/../library/Class”


From → Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: