<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Auto-loading vendor files (or any other file)</title>
	<atom:link href="http://cakebaker.42dh.com/2008/11/28/auto-loading-vendor-files-or-any-other-file/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2008/11/28/auto-loading-vendor-files-or-any-other-file/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Thu, 11 Mar 2010 15:41:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/11/28/auto-loading-vendor-files-or-any-other-file/comment-page-1/#comment-113985</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 04 Dec 2008 15:35:46 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=979#comment-113985</guid>
		<description>@David: Thanks for sharing this code! And yes, the SPL provides some nice things which, unfortunately, are not so well-known...</description>
		<content:encoded><![CDATA[<p>@David: Thanks for sharing this code! And yes, the SPL provides some nice things which, unfortunately, are not so well-known&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Thalmann</title>
		<link>http://cakebaker.42dh.com/2008/11/28/auto-loading-vendor-files-or-any-other-file/comment-page-1/#comment-113898</link>
		<dc:creator>David Thalmann</dc:creator>
		<pubDate>Wed, 03 Dec 2008 16:31:28 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=979#comment-113898</guid>
		<description>SPL supports nice classes and interfaces for searching/iterating (&lt;- *hint* ^^) through folders, together with autoload a very powerful feature of php5. But in large projects with deep folder structure is searching for classes slowing down everything. Possible solution: precached/automatic generated class list!

&lt;code&gt;&lt;?php
/**
 * Loads classes, search (recursively) in $path
 *
 * @todo speedup this function with precached filelist
 *
 * @param string $class
 * @param string $path
 * @param bool $recursive
 */
function autoloader($class, $path, $recursive = true) {
	$dir = new RecursiveDirectoryIterator($path);
	$dir_r = array();

	foreach($dir as $file) {
		if(!$file-&gt;isDir() &amp;&amp; $file == Inflector::underscore($class))
			require_once($class);
		elseif($file-&gt;isDir() &amp;&amp; $recursive &amp;&amp; substr($file-&gt;getFilename(), 0, 1) != &#039;.&#039;) // prevent loading folders like .svn
			$dir_r[] = $file;
	}

	if($recursive)
		foreach($dir_r as $dirs)
			autoloader($class, $dirs);
}

/**
 * autoload helper function
 *
 * @param string $class
 */
function core_autoloader($class) {
	$list = array(
		&#039;Inflector&#039;			=&gt; LIB.&#039;inflector.php&#039;,
		&#039;AnotherClass&#039;	=&gt; LIB.&#039;anotherClass.php&#039;
		/* more here */
	);

	if(array_key_exists($class, $list))
		require_once($list[$class]);
	else
		autoloader($class, CORE);
}

/**
 * Initialize the spl_autoload functions
 * - first activate the autoload function, no magic __autoload() method =)
 * - speed up searching with dropping the .inc extension and set .php as main extension
 * - register our fast autoload function
 */
spl_autoload_register(null);
spl_autoload_extensions(&#039;.php&#039;);
spl_autoload_register(&#039;core_autoloader&#039;);

?&gt;&lt;/code&gt;

Hope could help sb with this.</description>
		<content:encoded><![CDATA[<p>SPL supports nice classes and interfaces for searching/iterating (&lt;- *hint* ^^) through folders, together with autoload a very powerful feature of php5. But in large projects with deep folder structure is searching for classes slowing down everything. Possible solution: precached/automatic generated class list!</p>
<pre><code>&lt;?php
/**
 * Loads classes, search (recursively) in $path
 *
 * @todo speedup this function with precached filelist
 *
 * @param string $class
 * @param string $path
 * @param bool $recursive
 */
function autoloader($class, $path, $recursive = true) {
	$dir = new RecursiveDirectoryIterator($path);
	$dir_r = array();

	foreach($dir as $file) {
		if(!$file-&gt;isDir() &amp;&amp; $file == Inflector::underscore($class))
			require_once($class);
		elseif($file-&gt;isDir() &amp;&amp; $recursive &amp;&amp; substr($file-&gt;getFilename(), 0, 1) != '.') // prevent loading folders like .svn
			$dir_r[] = $file;
	}

	if($recursive)
		foreach($dir_r as $dirs)
			autoloader($class, $dirs);
}

/**
 * autoload helper function
 *
 * @param string $class
 */
function core_autoloader($class) {
	$list = array(
		'Inflector'			=&gt; LIB.'inflector.php',
		'AnotherClass'	=&gt; LIB.'anotherClass.php'
		/* more here */
	);

	if(array_key_exists($class, $list))
		require_once($list[$class]);
	else
		autoloader($class, CORE);
}

/**
 * Initialize the spl_autoload functions
 * - first activate the autoload function, no magic __autoload() method =)
 * - speed up searching with dropping the .inc extension and set .php as main extension
 * - register our fast autoload function
 */
spl_autoload_register(null);
spl_autoload_extensions('.php');
spl_autoload_register('core_autoloader');

?&gt;</code></pre>
<p>Hope could help sb with this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Автоматическая загрузка внешних библиотек - Программируем на CakePHP</title>
		<link>http://cakebaker.42dh.com/2008/11/28/auto-loading-vendor-files-or-any-other-file/comment-page-1/#comment-113871</link>
		<dc:creator>Автоматическая загрузка внешних библиотек - Программируем на CakePHP</dc:creator>
		<pubDate>Wed, 03 Dec 2008 05:34:35 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=979#comment-113871</guid>
		<description>[...] записи Auto-loading vendor files (or any other file) с блога [...]</description>
		<content:encoded><![CDATA[<p>[...] записи Auto-loading vendor files (or any other file) с блога [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/11/28/auto-loading-vendor-files-or-any-other-file/comment-page-1/#comment-113786</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 02 Dec 2008 15:19:56 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=979#comment-113786</guid>
		<description>@Juan: Thanks for your comment!

I don&#039;t think this will make it in the core any time soon, because Cake 1.2 still supports PHP4 and this is a PHP5 feature... But maybe the cake devs will make use of this feature in a later version of cake...</description>
		<content:encoded><![CDATA[<p>@Juan: Thanks for your comment!</p>
<p>I don&#8217;t think this will make it in the core any time soon, because Cake 1.2 still supports PHP4 and this is a PHP5 feature&#8230; But maybe the cake devs will make use of this feature in a later version of cake&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Juan Basso</title>
		<link>http://cakebaker.42dh.com/2008/11/28/auto-loading-vendor-files-or-any-other-file/comment-page-1/#comment-113774</link>
		<dc:creator>Juan Basso</dc:creator>
		<pubDate>Tue, 02 Dec 2008 10:00:42 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=979#comment-113774</guid>
		<description>I think that this feature can implemented in Cake core. Put the function on basics.php or implements a method in App class and use spl_autoload_register to call.
Maybe, if load fail, can find a Model, Component, ...</description>
		<content:encoded><![CDATA[<p>I think that this feature can implemented in Cake core. Put the function on basics.php or implements a method in App class and use spl_autoload_register to call.<br />
Maybe, if load fail, can find a Model, Component, &#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
