<?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: Write your own PHP MVC Framework (Part 1)</title>
	<atom:link href="http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/feed/" rel="self" type="application/rss+xml" />
	<link>http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/</link>
	<description>on web development</description>
	<pubDate>Wed, 22 May 2013 00:01:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Daniel</title>
		<link>http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/comment-page-3/#comment-38132</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Wed, 22 Feb 2012 10:28:27 +0000</pubDate>
		<guid isPermaLink="false">http://anantgarg.com/?p=69#comment-38132</guid>
		<description>Thanks a lot for this great tutorial! It helps me to understand MVC and to write my own small framework.</description>
		<content:encoded><![CDATA[<p>Thanks a lot for this great tutorial! It helps me to understand MVC and to write my own small framework.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/comment-page-3/#comment-37573</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Sat, 18 Feb 2012 01:33:59 +0000</pubDate>
		<guid isPermaLink="false">http://anantgarg.com/?p=69#comment-37573</guid>
		<description>Just a quick note for anyone else who might be still struggling with this error:

Fatal error: Class ‘ItemsController’ not found in localhost\library\shared.php on line 65.

I had this error for a long time and unlike most of the people above it was not related to the framework being inside another folder and then the url being incorrect.

Someone else may have done the same as I did, but in following with other MVC's I've seen I named the "applications" folder "app" during setup of the files. This means the urls are incorrect in the __autoload function as well as in the template.class.php file and you will need to change (for example) this line:

if (file_exists(ROOT . DS . 'applications' . DS . 'views' . DS . $this-&gt;_controller . DS . 'header.php')) {

to:

if (file_exists(ROOT . DS . 'app' . DS . 'views' . DS . $this-&gt;_controller . DS . 'header.php')) {

It took me a couple of frustrating hours to find that stupid error on my part. Hopefully this saves you and other debuggers some time.

Cheers.</description>
		<content:encoded><![CDATA[<p>Just a quick note for anyone else who might be still struggling with this error:</p>
<p>Fatal error: Class ‘ItemsController’ not found in localhost\library\shared.php on line 65.</p>
<p>I had this error for a long time and unlike most of the people above it was not related to the framework being inside another folder and then the url being incorrect.</p>
<p>Someone else may have done the same as I did, but in following with other MVC&#8217;s I&#8217;ve seen I named the &#8220;applications&#8221; folder &#8220;app&#8221; during setup of the files. This means the urls are incorrect in the __autoload function as well as in the template.class.php file and you will need to change (for example) this line:</p>
<p>if (file_exists(ROOT . DS . &#8216;applications&#8217; . DS . &#8216;views&#8217; . DS . $this-&gt;_controller . DS . &#8216;header.php&#8217;)) {</p>
<p>to:</p>
<p>if (file_exists(ROOT . DS . &#8216;app&#8217; . DS . &#8216;views&#8217; . DS . $this-&gt;_controller . DS . &#8216;header.php&#8217;)) {</p>
<p>It took me a couple of frustrating hours to find that stupid error on my part. Hopefully this saves you and other debuggers some time.</p>
<p>Cheers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: M2E</title>
		<link>http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/comment-page-3/#comment-34671</link>
		<dc:creator>M2E</dc:creator>
		<pubDate>Wed, 25 Jan 2012 17:48:50 +0000</pubDate>
		<guid isPermaLink="false">http://anantgarg.com/?p=69#comment-34671</guid>
		<description>Hi Anant Garg,
Thanks for the nice tutorial.
I have been working as a PHP developer for nearly 2 years. Still I found that this is very useful.
BTW to make the code workable without errors or warnings I think it’s better to do following modifications 

To shared.php.
under [if (ini_get('register_globals')) { ] line
if (empty($GLOBALS['_SESSION'])) {session_start(); }

Under [foreach ($GLOBALS[$value] as $key =&gt; $var) {] line
if (isset($GLOBALS[$key])) {…….}

Under [ global $url;]
if(!isset ($url)){
$url = $_GET['url'];
if(!isset ($url)){
$url = $_POST['url'];
}
}

One suggestion for the people who gets the error 404 for " http://localhost/xxxx/items/viewall"
In your apache http.conf uncomment the below line
LoadModule rewrite_module modules/mod_rewrite.so

One question, Could you explain from where “__autoload” function is called.

Thanks,
Muditha</description>
		<content:encoded><![CDATA[<p>Hi Anant Garg,<br />
Thanks for the nice tutorial.<br />
I have been working as a PHP developer for nearly 2 years. Still I found that this is very useful.<br />
BTW to make the code workable without errors or warnings I think it’s better to do following modifications </p>
<p>To shared.php.<br />
under [if (ini_get('register_globals')) { ] line<br />
if (empty($GLOBALS['_SESSION'])) {session_start(); }</p>
<p>Under [foreach ($GLOBALS[$value] as $key =&gt; $var) {] line<br />
if (isset($GLOBALS[$key])) {…….}</p>
<p>Under [ global $url;]<br />
if(!isset ($url)){<br />
$url = $_GET['url'];<br />
if(!isset ($url)){<br />
$url = $_POST['url'];<br />
}<br />
}</p>
<p>One suggestion for the people who gets the error 404 for &#8221; <a href="http://localhost/xxxx/items/viewall" rel="nofollow">http://localhost/xxxx/items/viewall</a>&#8221;<br />
In your apache http.conf uncomment the below line<br />
LoadModule rewrite_module modules/mod_rewrite.so</p>
<p>One question, Could you explain from where “__autoload” function is called.</p>
<p>Thanks,<br />
Muditha</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Muditha</title>
		<link>http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/comment-page-3/#comment-34571</link>
		<dc:creator>Muditha</dc:creator>
		<pubDate>Tue, 24 Jan 2012 18:08:32 +0000</pubDate>
		<guid isPermaLink="false">http://anantgarg.com/?p=69#comment-34571</guid>
		<description>For the error “The requested URL /XXX/items/viewall was not found on this server.”,
Try to uncomment the bellow line in Apache httpd.conf 
LoadModule rewrite_module modules/mod_rewrite.so</description>
		<content:encoded><![CDATA[<p>For the error “The requested URL /XXX/items/viewall was not found on this server.”,<br />
Try to uncomment the bellow line in Apache httpd.conf<br />
LoadModule rewrite_module modules/mod_rewrite.so</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: velu</title>
		<link>http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/comment-page-3/#comment-32785</link>
		<dc:creator>velu</dc:creator>
		<pubDate>Thu, 12 Jan 2012 07:29:21 +0000</pubDate>
		<guid isPermaLink="false">http://anantgarg.com/?p=69#comment-32785</guid>
		<description>plz explain this code


function callHook() {
	global $url;

	$urlArray = array();
	$urlArray = explode("/",$url);

	$controller = $urlArray[0];
	array_shift($urlArray);
	$action = $urlArray[0];
	array_shift($urlArray);
	$queryString = $urlArray;

	$controllerName = $controller;
	$controller = ucwords($controller);
	$model = rtrim($controller, 's');
	$controller .= 'Controller';
	$dispatch = new $controller($model,$controllerName,$action);

	if ((int)method_exists($controller, $action)) {
		call_user_func_array(array($dispatch,$action),$queryString);
	} else {
		/* Error Generation Code Here */
	}
}</description>
		<content:encoded><![CDATA[<p>plz explain this code</p>
<p>function callHook() {<br />
	global $url;</p>
<p>	$urlArray = array();<br />
	$urlArray = explode(&#8221;/&#8221;,$url);</p>
<p>	$controller = $urlArray[0];<br />
	array_shift($urlArray);<br />
	$action = $urlArray[0];<br />
	array_shift($urlArray);<br />
	$queryString = $urlArray;</p>
<p>	$controllerName = $controller;<br />
	$controller = ucwords($controller);<br />
	$model = rtrim($controller, &#8217;s&#8217;);<br />
	$controller .= &#8216;Controller&#8217;;<br />
	$dispatch = new $controller($model,$controllerName,$action);</p>
<p>	if ((int)method_exists($controller, $action)) {<br />
		call_user_func_array(array($dispatch,$action),$queryString);<br />
	} else {<br />
		/* Error Generation Code Here */<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pepe</title>
		<link>http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/comment-page-3/#comment-29916</link>
		<dc:creator>Pepe</dc:creator>
		<pubDate>Fri, 30 Dec 2011 04:31:12 +0000</pubDate>
		<guid isPermaLink="false">http://anantgarg.com/?p=69#comment-29916</guid>
		<description>Hi!

A really great MVC tutorial! 

Happy New Year mate, 

thanks!</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>A really great MVC tutorial! </p>
<p>Happy New Year mate, </p>
<p>thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xlordt</title>
		<link>http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/comment-page-3/#comment-27334</link>
		<dc:creator>xlordt</dc:creator>
		<pubDate>Mon, 19 Dec 2011 16:09:33 +0000</pubDate>
		<guid isPermaLink="false">http://anantgarg.com/?p=69#comment-27334</guid>
		<description>A bit outdated I know, although I would like to know how well will this work for production purposes for like say.. a medium site? The reason I ask is because I love the everyday learning phases... and I would love to use something like this on website.

Brilliant work btw.</description>
		<content:encoded><![CDATA[<p>A bit outdated I know, although I would like to know how well will this work for production purposes for like say.. a medium site? The reason I ask is because I love the everyday learning phases&#8230; and I would love to use something like this on website.</p>
<p>Brilliant work btw.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Navneet Saini</title>
		<link>http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/comment-page-3/#comment-20773</link>
		<dc:creator>Navneet Saini</dc:creator>
		<pubDate>Thu, 10 Nov 2011 07:09:20 +0000</pubDate>
		<guid isPermaLink="false">http://anantgarg.com/?p=69#comment-20773</guid>
		<description>Even 
15. $this-&gt;$model =&amp; new $model;
16. $this-&gt;_template =&amp; new Template($controller,$action);
will not work in 5.3.5 version of php to work these lline in 5.3.5 version you have to eliminate &amp; from code and you can write this as this way
15. $this-&gt;$model = new $model;
16. $this-&gt;_template = new Template($controller,$action);
But is was realy a nice tutorial 
Thanks for sharing this
Navneet Saini</description>
		<content:encoded><![CDATA[<p>Even<br />
15. $this-&gt;$model =&amp; new $model;<br />
16. $this-&gt;_template =&amp; new Template($controller,$action);<br />
will not work in 5.3.5 version of php to work these lline in 5.3.5 version you have to eliminate &amp; from code and you can write this as this way<br />
15. $this-&gt;$model = new $model;<br />
16. $this-&gt;_template = new Template($controller,$action);<br />
But is was realy a nice tutorial<br />
Thanks for sharing this<br />
Navneet Saini</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: suraj air</title>
		<link>http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/comment-page-3/#comment-18771</link>
		<dc:creator>suraj air</dc:creator>
		<pubDate>Sun, 16 Oct 2011 11:34:41 +0000</pubDate>
		<guid isPermaLink="false">http://anantgarg.com/?p=69#comment-18771</guid>
		<description>Hey, thanks a lot for giving such a valuable information. I had been looking for this stuff for long time.... thnx a lot.... :)</description>
		<content:encoded><![CDATA[<p>Hey, thanks a lot for giving such a valuable information. I had been looking for this stuff for long time&#8230;. thnx a lot&#8230;. <img src='http://anantgarg.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mitrajit Samanta</title>
		<link>http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/comment-page-3/#comment-18276</link>
		<dc:creator>Mitrajit Samanta</dc:creator>
		<pubDate>Sat, 08 Oct 2011 15:08:23 +0000</pubDate>
		<guid isPermaLink="false">http://anantgarg.com/?p=69#comment-18276</guid>
		<description>Hi Anant......
Thanks for you great MVC tutorials,
But I have faced a problem, when I enter the url in browser
http://localhost/framework/items/viewall

It shows me the error

Not Found

The requested URL /framework/items/viewall was not found on this server.

'I'm using WampServer2.1d. So what's the problem?
plz reply me.
Thanks again....</description>
		<content:encoded><![CDATA[<p>Hi Anant&#8230;&#8230;<br />
Thanks for you great MVC tutorials,<br />
But I have faced a problem, when I enter the url in browser<br />
<a href="http://localhost/framework/items/viewall" rel="nofollow">http://localhost/framework/items/viewall</a></p>
<p>It shows me the error</p>
<p>Not Found</p>
<p>The requested URL /framework/items/viewall was not found on this server.</p>
<p>&#8216;I&#8217;m using WampServer2.1d. So what&#8217;s the problem?<br />
plz reply me.<br />
Thanks again&#8230;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
