Page 1 of 1

__autoload

Posted: Sun Jun 03, 2007 4:27 pm
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 :)

Posted: Sun Jun 03, 2007 4:33 pm
by feyd
Have you read the previous threads where we've discussed service locators and/or autoload?

Posted: Sun Jun 03, 2007 5:18 pm
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. :)

Posted: Sun Jun 03, 2007 5:56 pm
by Kieran Huggins
The previous thread was quite long, but I think virtually everything about __autoload was discussed in there at some point.

Posted: Mon Jun 04, 2007 11:39 am
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.