<?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: Loading vendor files</title>
	<atom:link href="http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Mon, 15 Mar 2010 20:27:55 +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/03/26/loading-vendor-files/comment-page-1/#comment-130685</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Wed, 17 Jun 2009 14:52:40 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/#comment-130685</guid>
		<description>@francis: Thanks for sharing your solution!

An idea to simplify your function is to use CakePHP&#039;s Folder::findRecursive() to get the file names (as a side effect you would also get rid of using the &quot;private&quot; method Configure::__list()).</description>
		<content:encoded><![CDATA[<p>@francis: Thanks for sharing your solution!</p>
<p>An idea to simplify your function is to use CakePHP&#8217;s Folder::findRecursive() to get the file names (as a side effect you would also get rid of using the &#8220;private&#8221; method Configure::__list()).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: francis</title>
		<link>http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/comment-page-1/#comment-130653</link>
		<dc:creator>francis</dc:creator>
		<pubDate>Wed, 17 Jun 2009 03:24:49 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/#comment-130653</guid>
		<description>correction..

&lt;code&gt;
        //store folders in current directory
	$folders = Configure::__list($dir);
	foreach($folders as $folder)
	{
		read_my_dir(&quot;{$dir}/{$folder}&quot;);
	}
&lt;/code&gt;

&quot;read_my_dir&quot; was supposed to be &quot;importVendorFolder&quot;</description>
		<content:encoded><![CDATA[<p>correction..</p>
<pre><code>//store folders in current directory
	$folders = Configure::__list($dir);
	foreach($folders as $folder)
	{
		read_my_dir("{$dir}/{$folder}");
	}</code></pre>
<p>&#8220;read_my_dir&#8221; was supposed to be &#8220;importVendorFolder&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: francis</title>
		<link>http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/comment-page-1/#comment-130644</link>
		<dc:creator>francis</dc:creator>
		<pubDate>Wed, 17 Jun 2009 01:14:31 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/#comment-130644</guid>
		<description>i thought so.. thanks for the suggestion.. i did it and i think it worked fine.. ill post the code here.. maybe it&#039;ll be helpful to others too.. :)

&lt;code&gt;
// Recursively adds a whole folder as a vendor.
function importVendorFolder($dir)
{
	//store &quot;.php&quot; files in current directory
	$files = Configure::__list($dir, &quot;.php&quot;);
	foreach($files as $file)
	{
		//import php file.
		app::import(&quot;Vendor&quot;, $file);
	}
	//store folders in current directory
	$folders = Configure::__list($dir);
	foreach($folders as $folder)
	{
		read_my_dir(&quot;{$dir}/{$folder}&quot;);
	}	
}
&lt;/code&gt;

in here i used the built in cake function &quot;Configure::__list&quot; to check if the file is a folder or a file.. 

and to call it:
&lt;code&gt;
//parameter is path to the vendor folder.
importVendorFolder(&quot;../vendors/lib&quot;);
&lt;/code&gt;

hope this will be useful to you guys.. :D</description>
		<content:encoded><![CDATA[<p>i thought so.. thanks for the suggestion.. i did it and i think it worked fine.. ill post the code here.. maybe it&#8217;ll be helpful to others too.. :)</p>
<pre><code>// Recursively adds a whole folder as a vendor.
function importVendorFolder($dir)
{
	//store ".php" files in current directory
	$files = Configure::__list($dir, ".php");
	foreach($files as $file)
	{
		//import php file.
		app::import("Vendor", $file);
	}
	//store folders in current directory
	$folders = Configure::__list($dir);
	foreach($folders as $folder)
	{
		read_my_dir("{$dir}/{$folder}");
	}	
}</code></pre>
<p>in here i used the built in cake function &#8220;Configure::__list&#8221; to check if the file is a folder or a file.. </p>
<p>and to call it:<br />
<pre><code>//parameter is path to the vendor folder.
importVendorFolder("../vendors/lib");</code></pre>
<p>hope this will be useful to you guys.. :D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/comment-page-1/#comment-130613</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 16 Jun 2009 14:37:35 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/#comment-130613</guid>
		<description>@francis: Thanks for your comment!

As far as I know App::import() doesn&#039;t provide such a feature. And so you have to do it manually by looping over the file names of the respective folder and calling App::import() for each file. To make this functionality reusable, you might want to put it into its own method.

Hope that helps!</description>
		<content:encoded><![CDATA[<p>@francis: Thanks for your comment!</p>
<p>As far as I know App::import() doesn&#8217;t provide such a feature. And so you have to do it manually by looping over the file names of the respective folder and calling App::import() for each file. To make this functionality reusable, you might want to put it into its own method.</p>
<p>Hope that helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: francis</title>
		<link>http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/comment-page-1/#comment-130596</link>
		<dc:creator>francis</dc:creator>
		<pubDate>Tue, 16 Jun 2009 07:53:46 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/#comment-130596</guid>
		<description>hi there, is it possible to import just the folder name and it automatically import all the files that the folder contains?</description>
		<content:encoded><![CDATA[<p>hi there, is it possible to import just the folder name and it automatically import all the files that the folder contains?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/comment-page-1/#comment-124450</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 31 Mar 2009 14:55:10 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/#comment-124450</guid>
		<description>@Justin: You are welcome!</description>
		<content:encoded><![CDATA[<p>@Justin: You are welcome!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/comment-page-1/#comment-124113</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Fri, 27 Mar 2009 16:16:12 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/#comment-124113</guid>
		<description>Thanks for this, the DOCS never mentioned anything about it needing to be lower case. Was pulling my hair out until finding this.</description>
		<content:encoded><![CDATA[<p>Thanks for this, the DOCS never mentioned anything about it needing to be lower case. Was pulling my hair out until finding this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/comment-page-1/#comment-123262</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 17 Mar 2009 15:02:05 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/#comment-123262</guid>
		<description>@Anand: I&#039;m glad this article was helpful for you!</description>
		<content:encoded><![CDATA[<p>@Anand: I&#8217;m glad this article was helpful for you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anand</title>
		<link>http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/comment-page-1/#comment-123171</link>
		<dc:creator>Anand</dc:creator>
		<pubDate>Mon, 16 Mar 2009 05:09:43 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/#comment-123171</guid>
		<description>helped me a lot.Thanks</description>
		<content:encoded><![CDATA[<p>helped me a lot.Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/comment-page-1/#comment-114351</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Wed, 10 Dec 2008 16:09:27 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/03/26/loading-vendor-files/#comment-114351</guid>
		<description>@Alejandro: Thanks for your comment! Yes, in principle you can say that the short form can be used if you follow the cake naming conventions, and in the other cases you have to use the array with the &quot;file&quot; key.</description>
		<content:encoded><![CDATA[<p>@Alejandro: Thanks for your comment! Yes, in principle you can say that the short form can be used if you follow the cake naming conventions, and in the other cases you have to use the array with the &#8220;file&#8221; key.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
