__autoload

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

__autoload

Post by alex.barylski »

I've decided to look into using __autoload as a magical way to include my classes. Forever and a day I have disliked this idea for the following reasons:

1) Auto-magic techniques are difficult to figure out when you first walk into a new code base - unless well document which usually isn't the case
2) I've liked having the include dependencies handled by the class module itself. This also makes dependency browsers easier to write and as well makes code code easier to follow when stepping through file by file.

However the idea of a centralized include module is just more appealing than hundreds and possibly thousands of files all linking to each other.

1) Easier maintenance and logging would tell me alot about of dependencies
2) Better performance in avoiding duplicate inclusions (even using include_once)

The idea is simple, the class name is mapped to a physical directory using a simple array (class names don't map to directory directly as in Zend).

Maybe some trivial logging facility so I can see what files are needed on which request and can use that to navigate the directory structure and open appropriate files.

Anything else you can think of I might want to add to a quasi service locator type file such as this?

Cheers :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Have you read the previous threads where we've discussed service locators and/or autoload?
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

feyd wrote:Have you read the previous threads where we've discussed service locators and/or autoload?
Yea I've followed them, but not relgiously or anything. :)
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

The previous thread was quite long, but I think virtually everything about __autoload was discussed in there at some point.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

+1. I asked a question about __autoload and got a community response to it. You should try reading it. It is very informative.
Post Reply