<?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>Andrew Vayanis &#187; PHP</title>
	<atom:link href="http://www.vayanis.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vayanis.com</link>
	<description>... a little piece of my mind.</description>
	<lastBuildDate>Wed, 02 Feb 2011 05:05:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>OS X 10.6 (Snow Leopard) – using MAMP/PECL to install PHP extensions</title>
		<link>http://www.vayanis.com/2010/05/19/os-x-10-6-snow-leopard-using-mamppecl-to-install-php-extensions/</link>
		<comments>http://www.vayanis.com/2010/05/19/os-x-10-6-snow-leopard-using-mamppecl-to-install-php-extensions/#comments</comments>
		<pubDate>Wed, 19 May 2010 15:48:25 +0000</pubDate>
		<dc:creator>Andrew Vayanis</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[MAMP]]></category>
		<category><![CDATA[Pecl]]></category>

		<guid isPermaLink="false">http://www.vayanis.com/?p=88</guid>
		<description><![CDATA[Need help installing PHP extensions for OS X 10.6 (Snow Leopard) using MAMP and the included pecl binary? Well, you have come to the right place. If you have tried this on its own, you will notice that none of the extensions pecl builds will work with MAMP. This is because MAMP is compiled as [...]]]></description>
			<content:encoded><![CDATA[<p>Need help installing PHP extensions for OS X 10.6 (Snow Leopard) using MAMP and the included pecl binary?  Well, you have come to the right place.  If you have tried this on its own, you will notice that none of the extensions pecl builds will work with MAMP.  This is because MAMP is compiled as a 32-bit binary whereas pecl tries to build 64-bit PHP extensions.</p>
<p>[Update Feb. 1, 2011]</p>
<p>A much easier way to install PECL packages:</p>
<p><code>CFLAGS="-arch i386" ./pecl install</code></p>
<p><del datetime="2011-02-02T05:04:42+00:00">To get pecl working properly, make sure you have <a href="http://developer.apple.com/technologies/tools/xcode.html">Xcode</a> installed on you machine.  Next, you will need to get a copy of MAMP&#8217;s source and prepare it using 32-bit compile flags. You can download the MAMP source from the <a href="http://www.mamp.info/en/downloads/index.html">MAMP download page</a>. Running the .dmg should extract the source. After extracting the source run the following:</del><br />
<span id="more-88"></span><br />
<del datetime="2011-02-02T05:04:42+00:00"><code><br />
mkdir /Applications/MAMP/Library/Include/<br />
mv /path/to/extracted/mamp/source/ /Applications/MAMP/Library/Include/<br />
</code></del></p>
<p><del datetime="2011-02-02T05:04:42+00:00">Next you will want to extract the PHP package and do the following to prepare the package:</del></p>
<p><del datetime="2011-02-02T05:04:42+00:00"><code><br />
mv /Applications/MAMP/Library/Include/extracted_php_source/ /Applications/MAMP/bin/php5/include/php/<br />
cd /Applications/MAMP/bin/php5/include/php/<br />
MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --with-php-config=/Applications/MAMP/bin/php5/bin/php-config<br />
</code></del></p>
<p><del datetime="2011-02-02T05:04:42+00:00">Finally, you now can install pecl extensions with the following command:</del><br />
<del datetime="2011-02-02T05:04:42+00:00"><code><br />
MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' /Applications/MAMP/bin/php5/bin/pecl install<br />
</code></del></p>
<p>And that&#8217;s it! Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vayanis.com/2010/05/19/os-x-10-6-snow-leopard-using-mamppecl-to-install-php-extensions/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Zend Framework, A First Look</title>
		<link>http://www.vayanis.com/2008/03/14/zend-framework-a-first-look/</link>
		<comments>http://www.vayanis.com/2008/03/14/zend-framework-a-first-look/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 14:32:16 +0000</pubDate>
		<dc:creator>Andrew Vayanis</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Form]]></category>

		<guid isPermaLink="false">http://www.vayanis.com/2008/03/14/zend-framework-a-first-look/</guid>
		<description><![CDATA[Having used Code Igniter for some small projects at work, I recently decided to take the time to acquaint myself with the Zend Framework(ZF) so that I could build my own comparison between two of the most, in my opinion, developed and used PHP frameworks. While I love the flexibility and functionality offered by ZF, [...]]]></description>
			<content:encoded><![CDATA[<p>Having used <a href="http://www.codeigniter.com">Code Igniter</a> for some small projects at work, I recently decided to take the time to acquaint myself with the <a href="http://framework.zend.com">Zend Framework</a>(ZF) so that I could build my own comparison between two of the most, in my opinion, developed and used PHP frameworks.  While I love the flexibility and functionality offered by ZF, I have become very frustrated and annoyed with some of their documentation.  Even though it is detailed and expansive, it is no where near complete and somewhat frustrating to use.<br />
<span id="more-27"></span><br />
Zend_Form is a great example of this incomplete documentation.  Conceptually, I think the Zend_Form is great. It offers very useful, and much needed functionality for creating and validating forms within pages and although it offers 4 pages of documentation and highlights many features, it barely touches upon one of its most useful features: the ability to create a form by passing the constructor a Zend_Config_Ini object.  In its simplest form this amounts to the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$loginForm</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Form<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Zend_Config_Ini<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/path/to/form/config'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'login'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><em>This will create a Zend_Form object by passing it a Zend_Config_Ini object.</em></p>
<p>Unfortunately, when you decide to build a custom form using Zend_Config, the documentation on how this actually works, is extremely sparse.  There are three examples of using the Zend_Config, however, they are not commented and there is no explanation as to how it works, there is only a weak reference to PHP object oriented code from which to draw conclusions from.  Maybe, I am too used to the <a href="http://java.sun.com/javase/6/docs/api/">Java API documentation</a>.</p>
<p>Anyways, after a few days with ZF, it has become apparent to me, that ZF is a very well written, powerful, extensible, and versatile PHP framework.  However, due to its incomplete documentation, I would argue that its&#8217; learning curve is fairly high, much higher than Code Igniter&#8217;s.  In time though, I am sure the ZF developers will realize this, and make the effort to provide better documentation.  In the meantime though, I am going to continue to use ZF and hopefully, take it upon myself to provide some insight; a Zend_Form tutorial using Zend_Config is already in the works.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vayanis.com/2008/03/14/zend-framework-a-first-look/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Sending POST requests with PHP</title>
		<link>http://www.vayanis.com/2007/08/28/sending-post-requests-with-php/</link>
		<comments>http://www.vayanis.com/2007/08/28/sending-post-requests-with-php/#comments</comments>
		<pubDate>Tue, 28 Aug 2007 16:13:06 +0000</pubDate>
		<dc:creator>Andrew Vayanis</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://www.vayanis.com/2007/08/28/sending-post-requests-with-php/</guid>
		<description><![CDATA[I recently found myself writing a REST web service, which, in my opinion, is the easiest way to create a web service, for a project at work. Using XML.com&#8217;s How to Create a REST protocol as my Guide, I went to work. However, when I tried to create a service to update some data, I [...]]]></description>
			<content:encoded><![CDATA[<p>I recently found myself writing a REST web service, which, in my opinion, is the easiest way to create a web service, for a project at work.  Using XML.com&#8217;s <a href="http://www.xml.com/pub/a/2004/12/01/restful-web.html">How to Create a REST protocol</a> as my Guide, I went to work.  However, when I tried to create a service to update some data, I wasn&#8217;t sure how to send my data in a POST request using PHP.  After some stumbling around, I found what I was looking for on <a href="http://netevil.org/blog/2006/nov/http-post-from-php-without-curl">Wez Furlong&#8217;s blog</a> which led me to PHP&#8217;s documentation on <a href="http://www.php.net/manual/en/wrappers.http.php">HTTP and HTTPS wrappers</a>.</p>
<p>The following is a code snippet from the HTTP and HTTPS documentation that shows how to easily send data using HTTP POST:<br />
<span id="more-24"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$postdata</span> <span style="color: #339933;">=</span> <span style="color: #990000;">http_build_query</span><span style="color: #009900;">&#40;</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'var1'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'some content'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'var2'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'doh'</span>
    <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$opts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http'</span> <span style="color: #339933;">=&gt;</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'method'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'POST'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'header'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Content-type: application/x-www-form-urlencoded'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'content'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$postdata</span>
    <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$context</span>  <span style="color: #339933;">=</span> <span style="color: #990000;">stream_context_create</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$opts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://example.com/submit.php'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$context</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Quick Explanation</h3>
<ol>
<li><a href="http://us.php.net/http_build_query">http_build_query</a>: Generates an URL-encoded string from an associative array.  Example: array(&#8216;key1&#8242; => &#8216;value1&#8242;, &#8216;key2&#8242; => &#8216;value2&#8242;) becomes &#8220;key1=value1&#038;key2=value2&#8243;
<p>This properly encodes the data for the post transaction.</p>
</li>
<li><a href="http://us.php.net/manual/en/function.stream-context-create.php">stream_context_create</a>: Creates and returns a resource to a stream context from an associative array of arrays in the format <em>$arr['wrapper']['option'] = $value</em>
<p>This creates a linear output stream to be sent during the request transmission.</p>
</li>
<li><a href="http://us3.php.net/manual/en/function.file-get-contents.php">file_get_contents</a>: Acts exactly like file(); except that it reads an entire file into a string.
<p>This requests a file resource and puts the result into a string.</p>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.vayanis.com/2007/08/28/sending-post-requests-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

