<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Stop including class files and use __autoload() instead</title>
	<atom:link href="http://www.jaisenmathai.com/blog/2008/06/25/stop-including-class-files-and-use-__autoload-instead/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jaisenmathai.com/blog/2008/06/25/stop-including-class-files-and-use-__autoload-instead/</link>
	<description>A blog about killer code</description>
	<pubDate>Thu, 04 Dec 2008 21:21:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Peter Mescalchin</title>
		<link>http://www.jaisenmathai.com/blog/2008/06/25/stop-including-class-files-and-use-__autoload-instead/#comment-223</link>
		<dc:creator>Peter Mescalchin</dc:creator>
		<pubDate>Fri, 04 Jul 2008 08:16:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.jaisenmathai.com/blog/?p=31#comment-223</guid>
		<description>@jaisen: I remember reading similar reports with APC. With eAccelerator at least hits are certainly made to the bytecode cache when using this method after checking its stats.

I think the issue with APC might be to do with paths to scripts being relative, rather than absolute, which would be a problem __autoload() or not. The autoload wrapper I use uses a full path from the root of the file system - so maybe that's why I am having success?</description>
		<content:encoded><![CDATA[<p>@jaisen: I remember reading similar reports with APC. With eAccelerator at least hits are certainly made to the bytecode cache when using this method after checking its stats.</p>
<p>I think the issue with APC might be to do with paths to scripts being relative, rather than absolute, which would be a problem __autoload() or not. The autoload wrapper I use uses a full path from the root of the file system - so maybe that&#8217;s why I am having success?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jaisen</title>
		<link>http://www.jaisenmathai.com/blog/2008/06/25/stop-including-class-files-and-use-__autoload-instead/#comment-222</link>
		<dc:creator>jaisen</dc:creator>
		<pubDate>Fri, 04 Jul 2008 06:23:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.jaisenmathai.com/blog/?p=31#comment-222</guid>
		<description>@Mike, While I see troelskn's point...I'm going to have to agree with you on this one.  The points he brings up are extremely valid but I don't think this specific case is the best example of when the case insensitivity of PHP can "taken advantage of".</description>
		<content:encoded><![CDATA[<p>@Mike, While I see troelskn&#8217;s point&#8230;I&#8217;m going to have to agree with you on this one.  The points he brings up are extremely valid but I don&#8217;t think this specific case is the best example of when the case insensitivity of PHP can &#8220;taken advantage of&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jaisen</title>
		<link>http://www.jaisenmathai.com/blog/2008/06/25/stop-including-class-files-and-use-__autoload-instead/#comment-221</link>
		<dc:creator>jaisen</dc:creator>
		<pubDate>Fri, 04 Jul 2008 06:21:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.jaisenmathai.com/blog/?p=31#comment-221</guid>
		<description>@Peter, I know internally here at Yahoo there's been some discussion on times when apc does not cache require/include calls.  I don't want to speak out of ignorance because I can't remember the specifics but I  thought it had to do with dynamically created paths.  I want to find out for sure...I'm sure it'll be another blog post of it's own as that's a very important behavior to understand.</description>
		<content:encoded><![CDATA[<p>@Peter, I know internally here at Yahoo there&#8217;s been some discussion on times when apc does not cache require/include calls.  I don&#8217;t want to speak out of ignorance because I can&#8217;t remember the specifics but I  thought it had to do with dynamically created paths.  I want to find out for sure&#8230;I&#8217;m sure it&#8217;ll be another blog post of it&#8217;s own as that&#8217;s a very important behavior to understand.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Mescalchin</title>
		<link>http://www.jaisenmathai.com/blog/2008/06/25/stop-including-class-files-and-use-__autoload-instead/#comment-219</link>
		<dc:creator>Peter Mescalchin</dc:creator>
		<pubDate>Thu, 03 Jul 2008 11:24:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.jaisenmathai.com/blog/?p=31#comment-219</guid>
		<description>@wesley - __autoload() doesn't do the require/include itself, you need to define the function - which in most cases will wrap a require/include call - so to answer your question, yes APC/eAccelerator will still function - its still require/include under the covers.

Another great thing with __autoload() it works with 'extends'... e.g.


class myclass extends baseclass {}


__autoload() will be called for both 'myclass' and 'baseclass'.

I do a similar system to "troelskn/PEAR", using underscores to name my classes, then breaking that down into subfolders in my class folder. One file per class works really well for me. __autoload() is a godsend.</description>
		<content:encoded><![CDATA[<p>@wesley - __autoload() doesn&#8217;t do the require/include itself, you need to define the function - which in most cases will wrap a require/include call - so to answer your question, yes APC/eAccelerator will still function - its still require/include under the covers.</p>
<p>Another great thing with __autoload() it works with &#8216;extends&#8217;&#8230; e.g.</p>
<p>class myclass extends baseclass {}</p>
<p>__autoload() will be called for both &#8216;myclass&#8217; and &#8216;baseclass&#8217;.</p>
<p>I do a similar system to &#8220;troelskn/PEAR&#8221;, using underscores to name my classes, then breaking that down into subfolders in my class folder. One file per class works really well for me. __autoload() is a godsend.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Cubes</title>
		<link>http://www.jaisenmathai.com/blog/2008/06/25/stop-including-class-files-and-use-__autoload-instead/#comment-218</link>
		<dc:creator>Mike Cubes</dc:creator>
		<pubDate>Wed, 02 Jul 2008 19:55:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.jaisenmathai.com/blog/?p=31#comment-218</guid>
		<description>@troelskn Just because it is valid PHP to write a class name in whatever case you want to at the time, doesn't mean it is a good idea. Writing all your code under the assumption that the language and the OS are both case-sensitive is a great way to have maintainable, portable, well written code. Yes, I know that PHP is case-insensitive, but that doesn't mean we as developers have to be. Defining MyClass, then using myClass looks amateur and doesn't follow a consistent pattern. The hack of running strtolower() inside of __autoload() to account for lazy programmers seams like a waste of a function call to me.</description>
		<content:encoded><![CDATA[<p>@troelskn Just because it is valid PHP to write a class name in whatever case you want to at the time, doesn&#8217;t mean it is a good idea. Writing all your code under the assumption that the language and the OS are both case-sensitive is a great way to have maintainable, portable, well written code. Yes, I know that PHP is case-insensitive, but that doesn&#8217;t mean we as developers have to be. Defining MyClass, then using myClass looks amateur and doesn&#8217;t follow a consistent pattern. The hack of running strtolower() inside of __autoload() to account for lazy programmers seams like a waste of a function call to me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wesley</title>
		<link>http://www.jaisenmathai.com/blog/2008/06/25/stop-including-class-files-and-use-__autoload-instead/#comment-216</link>
		<dc:creator>wesley</dc:creator>
		<pubDate>Wed, 02 Jul 2008 16:51:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.jaisenmathai.com/blog/?p=31#comment-216</guid>
		<description>What about APC and others, will they still be able to optimize/cache php requests equally well as when you use require?</description>
		<content:encoded><![CDATA[<p>What about APC and others, will they still be able to optimize/cache php requests equally well as when you use require?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jasper</title>
		<link>http://www.jaisenmathai.com/blog/2008/06/25/stop-including-class-files-and-use-__autoload-instead/#comment-214</link>
		<dc:creator>Jasper</dc:creator>
		<pubDate>Sat, 28 Jun 2008 22:58:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.jaisenmathai.com/blog/?p=31#comment-214</guid>
		<description>I love the autoload function, but have found it quite difficult to convince people of its benefits!

I personally do what troelskn said in the first comment - lowercase all directories and filenames, classes are like Model_Core and User_Model are in core/model.php and model/user.php for portability - never know what sort operating systems clients are going to be using on their servers!</description>
		<content:encoded><![CDATA[<p>I love the autoload function, but have found it quite difficult to convince people of its benefits!</p>
<p>I personally do what troelskn said in the first comment - lowercase all directories and filenames, classes are like Model_Core and User_Model are in core/model.php and model/user.php for portability - never know what sort operating systems clients are going to be using on their servers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: troelskn</title>
		<link>http://www.jaisenmathai.com/blog/2008/06/25/stop-including-class-files-and-use-__autoload-instead/#comment-206</link>
		<dc:creator>troelskn</dc:creator>
		<pubDate>Fri, 27 Jun 2008 08:36:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.jaisenmathai.com/blog/?p=31#comment-206</guid>
		<description>@Marc But you're _not_ trying to load a file; You're trying to instantiate a class. It is valid PHP syntax, to write the classname in whichever case, you want. So you will get no error on Windows, but you would on unix. That makes your program non-portable. That's a pretty good reason in my book.</description>
		<content:encoded><![CDATA[<p>@Marc But you&#8217;re _not_ trying to load a file; You&#8217;re trying to instantiate a class. It is valid PHP syntax, to write the classname in whichever case, you want. So you will get no error on Windows, but you would on unix. That makes your program non-portable. That&#8217;s a pretty good reason in my book.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marc</title>
		<link>http://www.jaisenmathai.com/blog/2008/06/25/stop-including-class-files-and-use-__autoload-instead/#comment-205</link>
		<dc:creator>Marc</dc:creator>
		<pubDate>Thu, 26 Jun 2008 22:56:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.jaisenmathai.com/blog/?p=31#comment-205</guid>
		<description>Failing to load Foobar.php when the file is called FooBar.php is in my opinion a good thing.  In my world, the class filename and  the class name are identical (except for the .php extention).  Makes autoloading by convention straight forward.

I've never understood the argument "keep your files in lower-case because the OS is case-sensitive).</description>
		<content:encoded><![CDATA[<p>Failing to load Foobar.php when the file is called FooBar.php is in my opinion a good thing.  In my world, the class filename and  the class name are identical (except for the .php extention).  Makes autoloading by convention straight forward.</p>
<p>I&#8217;ve never understood the argument &#8220;keep your files in lower-case because the OS is case-sensitive).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: troelskn</title>
		<link>http://www.jaisenmathai.com/blog/2008/06/25/stop-including-class-files-and-use-__autoload-instead/#comment-204</link>
		<dc:creator>troelskn</dc:creator>
		<pubDate>Thu, 26 Jun 2008 22:05:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.jaisenmathai.com/blog/?p=31#comment-204</guid>
		<description>&#62; It hadn’t crossed my mind before that class A and class a defined in A.php and a.php respectively could cause lots of headaches

A more realistic scenario would be, that you have defined class FooBar in FooBar.php, and write some code like this:
$f = new Foobar();

This will trigger __autoload() to load up Foobar.php, which doesn't exist (It's FooBar.php). Not entirely far fetched.</description>
		<content:encoded><![CDATA[<p>&gt; It hadn’t crossed my mind before that class A and class a defined in A.php and a.php respectively could cause lots of headaches</p>
<p>A more realistic scenario would be, that you have defined class FooBar in FooBar.php, and write some code like this:<br />
$f = new Foobar();</p>
<p>This will trigger __autoload() to load up Foobar.php, which doesn&#8217;t exist (It&#8217;s FooBar.php). Not entirely far fetched.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
