<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>PHP Architect blog &#187; error</title>
	<atom:link href="http://www.php-architect.com/blog/tag/error/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.php-architect.com/blog</link>
	<description>me, myself, and my code</description>
	<lastBuildDate>Wed, 14 Sep 2011 12:50:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Smart Debugging with Zend Framework</title>
		<link>http://www.php-architect.com/blog/2009/04/03/smart-debugging-with-zend-framework/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=smart-debugging-with-zend-framework</link>
		<comments>http://www.php-architect.com/blog/2009/04/03/smart-debugging-with-zend-framework/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 12:35:28 +0000</pubDate>
		<dc:creator>aibrahim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[zf]]></category>
		<guid isPermaLink="false">http://www.php-architect.com/blog/?p=294</guid>
		<description><![CDATA[<a href="http://www.php-architect.com/blog/2009/04/03/smart-debugging-with-zend-framework/" title="Smart Debugging with Zend Framework"></a>Sometimes your clients report to you Errors you have never experienced while testing your web application, or broken links, or some errors that occurs under some scenarios that you didn&#8217;t apply. There is a smart trick i do in the &#8230;<p class="read-more"><a href="http://www.php-architect.com/blog/2009/04/03/smart-debugging-with-zend-framework/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.php-architect.com/blog/2009/04/03/smart-debugging-with-zend-framework/" title="Smart Debugging with Zend Framework"></a><iframe src="http://www.facebook.com/plugins/like.php?href=http://www.php-architect.com/blog/2009/04/03/smart-debugging-with-zend-framework/&amp;layout=standard&amp;show_faces=1&amp;width=450&amp;action=like&amp;colorscheme=light&amp;font=" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px"></iframe><p>Sometimes your clients report to you Errors you have never experienced while testing your web application, or broken links, or some errors that occurs under some scenarios that you didn&#8217;t apply.</p>
<p>There is a smart trick i do in the ErrorController in my Zend Framework applications, i make the application send me the same error it displays to the user direct to my email, so i can know under what circumstances and conditions that error occurred.</p>
<p>The sweet thing is that when google bot or any search engine crawls my websites, they find some errors also, errors that i and the client didn&#8217;t reach, so i get the chance to fix it before any body see it.</p>
<p>I also sometimes disable viewing the error message and display &#8220;Some errors has occurred and the support has been notified, sorry for the inconvenience&#8221; and provide a link to go to Homepage for example.</p>
<p>Below is the code i have in my ErrorController :</p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000088;">$errors</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_getParam<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'error_handler'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$errors</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">case</span> Zend_Controller_Plugin_ErrorHandler<span style="color: #339933;">::</span><span style="color: #004000;">EXCEPTION_NO_CONTROLLER</span><span style="color: #339933;">:</span>
            <span style="color: #b1b100;">case</span> Zend_Controller_Plugin_ErrorHandler<span style="color: #339933;">::</span><span style="color: #004000;">EXCEPTION_NO_ACTION</span><span style="color: #339933;">:</span>
                <span style="color: #666666; font-style: italic;">// 404 error -- controller or action not found                </span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRawHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP/1.1 404 Not Found'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'HTTP/1.1 404 Not Found'</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
                <span style="color: #666666; font-style: italic;">// application error; display error page, but don't change                </span>
                <span style="color: #666666; font-style: italic;">// status code</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Application Error'</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$body</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'HTTP/1.1 404 Not Found'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$body</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$errors</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">exception</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$body</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;IP Address: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$body</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;User Agent: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$body</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Lang: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_ACCEPT_LANGUAGE'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$body</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Referer Link: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_REFERER'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$body</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Requested URL&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
		<span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Mail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setBodyHtml</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFrom</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'support@somesite.com'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Website Support'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addTo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ahmed.abdelaliem@mysite.com.com&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Ahmed Abdel-ALiem&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setSubject</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Sitename Error Occurred'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">message</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$errors</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">exception</span><span style="color: #339933;">;</span></pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.php-architect.com/blog/2009/04/03/smart-debugging-with-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

