<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Internet Strategy Guide</title>
	
	<link>http://phpprotip.com</link>
	<description>Together we can defeat the internet</description>
	<lastBuildDate>Sat, 11 Feb 2012 01:39:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/phpprotip" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="phpprotip" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>PHPStorm File Templates Includes Custom Variables</title>
		<link>http://phpprotip.com/2012/02/phpstorm-file-templates-includes-custom-variables/</link>
		<comments>http://phpprotip.com/2012/02/phpstorm-file-templates-includes-custom-variables/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 01:39:46 +0000</pubDate>
		<dc:creator>chance</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpstorm]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://phpprotip.com/?p=564</guid>
		<description><![CDATA[PHPStorm's File template settings are very versatile. They allow you to not only make a file template, but also allow you to parse out redundant elements (such as licensing) in the template by allowing an includes section. In your File Template, any undefined variable automatically elicits a prompt from PHPStorm. PHPStorm allows you access to the [...]]]></description>
			<content:encoded><![CDATA[<p>PHPStorm's File template settings are very versatile. They allow you to not only make a file template, but also allow you to parse out redundant elements (such as licensing) in the template by allowing an includes section. In your File Template, any undefined variable automatically elicits a prompt from PHPStorm.</p>
<p>PHPStorm allows you access to the includes section via the <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5qZXRicmFpbnMuY29tL3BocHN0b3JtL3dlYmhlbHAvcGFyc2UtZGlyZWN0aXZlLmh0bWw=">#parse directive</a>. If you're want To have Custom variables to be filled in correctly via prompt, you will need to have the variable declared in the template.</p>
<p>Example</p>
<p>"chance license.php"</p>
<pre class="php"><span style="color: #808080; font-style: italic;">/**
* @package ${Package}
* @author Chance Garcia
* @copyright (C)Copyright ${YEAR} chancegarcia.com
*/</span></pre>
<p>In the above includes example, I'm wanting to have a custom variable named Package. I can only cause PHPStorm to prompt for this value if I include the variable in my template. If I'm already using the variable in the template, then it will fill in when the includes file is parsed.</p>
<p>Example:</p>
<pre class="php">&amp;lt;?php
<span style="color: #808080; font-style: italic;">#parse(&quot;chance license.php&quot;)</span>
&nbsp;
<span style="color: #006699; font-weight: bold;">class</span> $<span style="color: #66cc66;">&#123;</span>Package<span style="color: #66cc66;">&#125;</span><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L18="><span style="color: #006666;">_</span></a><span style="color: #808080; font-style: italic;">#if(${ExtraClassInfo} != &quot;&quot;)${ExtraClassInfo}_#end${NAME}</span>
<span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre>
<p>In the above template, the ${Package} variable will be given a prompt since it is used in the template and an unknown variable and the parsed "chance license.php" include will be able to use that prompt value.</p>
<p>I am also using another variable to Prompt for extra class name information. Since PHPStorm uses <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3ZlbG9jaXR5LmFwYWNoZS5vcmcvZW5naW5lL2RldmVsL3Z0bC1yZWZlcmVuY2UtZ3VpZGUuaHRtbA==">Velocity Template Language (VTL)</a>, I am able to use the VTL conditional syntax to insert that information if it is entered and ignore it if it is not. This technique is useful in a situation where you want your include file to have a custom variable value but do not need to display this value in your template.</p>
<p>Example:</p>
<pre class="xml"><span style="color: #ddbb00;">&amp;lt;</span>?xml version=&quot;1.0&quot;?<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>!--
#if(${Package})#end
#parse(&quot;chance license.php&quot;)
--<span style="color: #ddbb00;">&amp;gt;</span></pre>
<p>&nbsp;</p>
<p>In the above example, we make PHPStorm prompt for the custom value needed for out parsed include file. This gives us our expected include file without printing our custom variable anywhere else in our template.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class=\"zemanta-pixie-a\" title=\"Enhanced by Zemanta\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy56ZW1hbnRhLmNvbS8="><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/zemified_c.png?x-id=74b10d0c-17e4-4dbd-a530-9c4de19c1ed6" alt="Enhanced by Zemanta" /></a></div>
 <img src="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=564" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://phpprotip.com/2012/02/phpstorm-file-templates-includes-custom-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MAMP PRO, PECL, SSH2, and OSX CLI (AKA acronym madness)</title>
		<link>http://phpprotip.com/2011/11/mamp-pro-pecl-ssh2-and-osx-cli-aka-acronym-madness/</link>
		<comments>http://phpprotip.com/2011/11/mamp-pro-pecl-ssh2-and-osx-cli-aka-acronym-madness/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 05:47:02 +0000</pubDate>
		<dc:creator>chance</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://phpprotip.com/?p=548</guid>
		<description><![CDATA[Install the PECL SSH2 extension to MAMP PRO and the PHP CLI in OSX.]]></description>
			<content:encoded><![CDATA[<p>Or madness in general. So as you may know, I've started using <a class=\"zem_slink\" title=\"PhpStorm\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5qZXRicmFpbnMuY29tL3BocHN0b3Jt" rel=\"homepage nofollow\">PHPStorm</a> to work locally. I decided to dust off an old <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cHM6Ly9naXRodWIuY29tL2NoYW5jZWdhcmNpYS9DRy9ibG9iL2dpdGh1Yi9Tc2gucGhw">SSH2 wrapper</a> I wrote and play with how PHPStorm uses <a class=\"zem_slink\" title=\"PHPUnit\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHB1bml0LmRl" rel=\"homepage nofollow\">PHPUnit</a> and does <a class=\"zem_slink\" title=\"Code refactoring\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Db2RlX3JlZmFjdG9yaW5n" rel=\"wikipedia nofollow\">refactoring</a>. I knew that I would have to install the extension via PECL and was like, "Oh it can't be that bad to do it through <a class=\"zem_slink\" title=\"MAMP\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5tYW1wLmluZm8vZW4vaW5kZXgucGhw" rel=\"homepage nofollow\">MAMP</a> PRO" and as you may have guessed, I sealed my own fate for a couple hours. One thing I can say is that, even though I use a convenient app like MAMP PRO to set up my local development environment, I'm glad my sysadmin-fu is up to snuff enough to fly without the conveniences because after this ordeal, I feel like I might as well have made my MAMP stack from scratch with all the hoops I jumped tonight. (I'm pretty sure that last sentence is also one of the worst run-on sentences ever).</p>
<p>The first thing you need to know is that the PECL command is located at the directory</p>
<pre>/Applications/MAMP/bin/php/php5.3.6/bin</pre>
<p>when I tried to run</p>
<pre>sudo ./pecl install -a ssh2 channel://pecl.php.net/ssh2-0.11.3</pre>
<p>from that directory, I got the error:</p>
<pre>Notice: unserialize(): Error at offset 267 of 1133 bytes in Config.php on line 1050
PHP Notice: unserialize(): Error at offset 267 of 1133 bytes in /Applications/MAMP/bin/php/php5.3.6/lib/php/PEAR/Config.php on line 1050
ERROR: The default config file is not a valid config file or is corrupted.</pre>
<p>I found out later that the error is most likely caused by the file</p>
<pre>/Applications/MAMP/bin/php/php5.3.6/conf/pear.conf</pre>
<p>So if you get an error, try doing</p>
<pre>sudo mv /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf.bkp</pre>
<p>If you're still getting the error, you can also the following:</p>
<ol>
<li>Install <a class=\"zem_slink\" title=\"Xcode\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2RldmVsb3Blci5hcHBsZS5jb20vdG9vbHMveGNvZGUv" rel=\"homepage nofollow\">Xcode Tools</a> from your <a class=\"zem_slink\" title=\"Mac OS X\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5hcHBsZS5jb20vbWFjb3N4Lw==" rel=\"homepage nofollow\">Mac OS X</a> <a class=\"zem_slink\" title=\"DVD\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9EVkQ=" rel=\"wikipedia nofollow\">DVD</a> or download it from <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2RldmVsb3Blci5hcHBsZS5jb20vdG9vbHMvZG93bmxvYWQv">Apple Developer Connection</a></li>
<li>Download the <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L2Rvd25sb2Fkcy5waHA=">complete PHP source code</a> from php.net into /Applications/MAMP/bin/php/php5.3.6/</li>
<li>Create an include directory in the the php5.3.6 directory.</li>
<li>Unzip/tar the php source archive and move it to/Applications/MAMP/bin/php/php5.3.6/include/</li>
<li>Rename the php source directory to just php (so then it will look like /Applications/MAMP/bin/php/php5.3.6/include/php)</li>
<li>In Terminal use the following commands to compile the extension:<br />
<code>cd /Applications/MAMP/bin/php/php5.3.6/include/php<br />
./configure</code></li>
</ol>
<p>That should allow you to run the PECL command however, you will probably get a complaint about not having libssh installed. So you will have to</p>
<ol>
<li>go download libssh2 (http://www.libssh2.org/). As much as I like git, I recommend  downloading the latest release tarball instead of cloning the repo. For some reason, I got a version incompatibility error when trying to run the PECL install with the repo version and had to do all these steps over with the tarball release version.</li>
<li>unzip the directory and cd to the upacked directory in the terminal.</li>
<li>run: ./configure; make all install;<br />
libssh should compile and place the output file in src/*.o</li>
<li>copy all headers from the include folder within the libssh2 directory to<br />
/usr/local/include/</li>
<li>copy all compiled files (*.o) from the src folder within the libssh2<br />
directory to /usr/local/lib/</li>
</ol>
<p>After you've successfully ran the the PECL install, it should tell you to  Add the line</p>
<pre>extension=ssh2.so</pre>
<p>to the Dynamic Extensions area of your php.ini file. I believe both MAMP and MAMP PRO allow you to edit the necessary ini through File&gt;Edit Template.</p>
<p><a title=\"MAMP edit php.ini by chancegarcia, on Flickr\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5mbGlja3IuY29tL3Bob3Rvcy9jaGFuY2VnYXJjaWEvNjMyNDM5MzEzOS8="><img src="http://phpprotip.com/wp-content/uploads/2011/11/6324393139_2310314308_z.jpg" alt="MAMP edit php.ini" width="640" height="409" /></a></p>
<p>&nbsp;</p>
<h3></h3>
<p>Lastly, restart apache. You should be able to see the SSH2 extension when you load a phpinfo() page.</p>
<h3>Bonus round:</h3>
<p>I'm not sure how I have  PHP CLI working in OSX but if you've followed the steps above and try to verify the extension install with through the cli, it won't show up.</p>
<pre>$ php -a</pre>
<pre>php&gt; phpinfo();</pre>
<p>This is because (if you're also using MAMP PRO) the binaries are different. The good news is that you can make things happy in 3 easy steps</p>
<ol>
<li>run `sudo ln -s /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/ssh2.so /usr/lib/php/extensions/no-debug-non-zts-20090626/ssh2.so` in the terminal.</li>
<li> Edit the /etc/php.ini (copy /etc/php.ini.default if /etc/php.ini doesn't exist)  like you did for the MAMP php.ini(s)</li>
<li>profit.</li>
</ol>
<p>Note: I still have to install PHPUnit into my current setup so that may or may not elicit another blog post.</p>
<p>Sources:</p>
<ul>
<li>http://smbjorklund.no/how-enable-pecl-uploadprogress-extention-mamp</li>
<li>http://php.net/manual/en/ref.ssh2.php</li>
<li>http://forum.mamp.info/viewtopic.php?t=13815</li>
</ul>
<h6 class="zemanta-related-title" style="font-size: 1em;">Related articles</h6>
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3BocHByb3RpcC5jb20vMjAxMS8xMC91c2luZy1teXNxbC13b3JrYmVuY2gtd2l0aC1tYW1wLw==" rel=\"nofollow\">Using MySQL Workbench with MAMP</a> (phpprotip.com)</li>
</ul>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class=\"zemanta-pixie-a\" title=\"Enhanced by Zemanta\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy56ZW1hbnRhLmNvbS8="><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/zemified_c.png?x-id=ae7de94f-8966-4782-8ef6-dd4e35b83e0b" alt="Enhanced by Zemanta" /></a></div>
 <img src="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=548" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://phpprotip.com/2011/11/mamp-pro-pecl-ssh2-and-osx-cli-aka-acronym-madness/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Magento Extension GitIgnore Stub</title>
		<link>http://phpprotip.com/2011/10/magento-extension-gitignore-stub/</link>
		<comments>http://phpprotip.com/2011/10/magento-extension-gitignore-stub/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 15:15:57 +0000</pubDate>
		<dc:creator>chance</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://phpprotip.com/?p=538</guid>
		<description><![CDATA[As you may or may not know, I've been working with Magento lately. In the past few months, one thing I've found that I needed is a stock .gitignore file for when making extensions. Haven't found one so I made one on github and will also post here for anyone else in need. I'm still [...]]]></description>
			<content:encoded><![CDATA[<p>As you may or may not know, I've been working with Magento lately. In the past few months, one thing I've found that I needed is a stock .gitignore file for when making extensions. Haven't found one so I made one on github and will also post here for anyone else in need. I'm still relatively new at working with Magento and in someways git/github so please feel free to critique/streamline.</p>
<p><code><br />
# replace {company} and {extension} placeholders with your information</code></p>
<p># ignore phpstorm files<br />
/.idea</p>
<p># Ignore all not in app &amp; skin<br />
/*<br />
!/app/<br />
!/js/</p>
<p># ignore all in js, except module files for this module<br />
/js/*<br />
!/js/{company}/</p>
<p># Ignore all in app, except code &amp; etc<br />
# Ignore all in app/code except /local/{company}<br />
/app/*<br />
!/app/code/<br />
!/app/etc/<br />
!/app/design/</p>
<p># Ignore all in app/code/local except {company}<br />
/app/code/core<br />
/app/code/community<br />
/app/code/local/*<br />
!app/code/local/{company}/<br />
# use lines below if you have multiple company extensions<br />
# and want to just commit a specific one<br />
#/app/code/local/{company}/*<br />
#!app/code/local/{company}/{extension}</p>
<p># Ignore all of app/etc except our specific module files<br />
/app/etc/*<br />
!/app/etc/modules/<br />
/app/etc/modules/*<br />
!/app/etc/modules/{company}_{package}.xml</p>
<p>#Ignore all of app/design except for our files<br />
/app/design/*<br />
!app/design/frontend/<br />
!app/design/adminhtml/<br />
/app/design/frontend/*<br />
!/app/design/frontend/base/<br />
/app/design/frontend/base/default/etc/<br />
/app/design/frontend/base/default/template/*<br />
!/app/design/frontend/base/default/template/{extension}/<br />
/app/design/frontend/base/default/layout/*<br />
!/app/design/frontend/base/default/layout/{extension}/*<br />
/app/design/adminhtml/*<br />
!/app/design/adminhtml/default/<br />
/app/design/adminhtml/default/find/<br />
/app/design/adminhtml/default/default/etc/<br />
/app/design/adminhtml/default/default/locale/<br />
/app/design/adminhtml/default/default/template/*<br />
!/app/design/adminhtml/default/default/template/{extension}/<br />
/app/design/adminhtml/default/default/layout/*<br />
!/app/design/adminhtml/default/default/layout/{extension}/*</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class=\"zemanta-pixie-a\" title=\"Enhanced by Zemanta\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy56ZW1hbnRhLmNvbS8="><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/zemified_c.png?x-id=882d30ec-f6e8-466a-99b2-88abcac3bdd9" alt="Enhanced by Zemanta" /></a></div>
 <img src="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=538" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://phpprotip.com/2011/10/magento-extension-gitignore-stub/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using MySQL Workbench with MAMP</title>
		<link>http://phpprotip.com/2011/10/using-mysql-workbench-with-mamp/</link>
		<comments>http://phpprotip.com/2011/10/using-mysql-workbench-with-mamp/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 06:07:52 +0000</pubDate>
		<dc:creator>chance</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://phpprotip.com/?p=527</guid>
		<description><![CDATA[Recently I've started working locally due to the PHPStorm IDE. In order to work locally, I invested in MAMP Pro to make use of their GUI interface for configuring vhosts. I also like to use MySQL Workbench for my database work, unfortunately these 2 items never seemed to work together for me before.]]></description>
			<content:encoded><![CDATA[<p>Recently I've started working locally due to the <a class=\"zem_slink\" title=\"PhpStorm\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5qZXRicmFpbnMuY29tL3BocHN0b3Jt" rel=\"homepage nofollow\">PHPStorm</a> <a class=\"zem_slink\" title=\"Integrated development environment\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9JbnRlZ3JhdGVkX2RldmVsb3BtZW50X2Vudmlyb25tZW50" rel=\"wikipedia nofollow\">IDE</a>. In order to work locally, I invested in <a class=\"zem_slink\" title=\"MAMP\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5tYW1wLmluZm8vZW4vaW5kZXgucGhw" rel=\"homepage nofollow\">MAMP</a> Pro to make use of their <a class=\"zem_slink\" title=\"Graphical user interface\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9HcmFwaGljYWxfdXNlcl9pbnRlcmZhY2U=" rel=\"wikipedia nofollow\">GUI</a> interface for configuring vhosts. I also like to use <a class=\"zem_slink\" title=\"MySQL Workbench\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3diLm15c3FsLmNvbS8=" rel=\"homepage nofollow\">MySQL Workbench</a> for my database work, unfortunately these 2 items never seemed to work together for me before. After a brief google search I was able to find out how to connect to MAMP's <a class=\"zem_slink\" title=\"MySQL\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5teXNxbC5jb20=" rel=\"homepage nofollow\">MySQL</a> install to do <a class=\"zem_slink\" title=\"SQL\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5pc28ub3JnL2lzby9jYXRhbG9ndWVfZGV0YWlsLmh0bT9jc251bWJlcj00NTQ5OA==" rel=\"homepage nofollow\">SQL</a> Development, which is by done by choosing the local socket connection method and using the value /Applications/MAMP/tmp/mysql/mysql.sock for the connection.</p>
<div><a title=\"MySQL Workbench MAMP Socket Connection Settings by chancegarcia, on Flickr\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5mbGlja3IuY29tL3Bob3Rvcy9jaGFuY2VnYXJjaWEvNjIxOTYwNzQxOC8="><img src="http://phpprotip.com/wp-content/uploads/2011/10/6219607418_984dde5d08_z.jpg" alt="MySQL Workbench MAMP Socket Connection Settings" width="640" height="170" /></a></div>
<div><a title=\"MySQL Workbench MAMP Connection Settings by chancegarcia, on Flickr\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5mbGlja3IuY29tL3Bob3Rvcy9jaGFuY2VnYXJjaWEvNjIxOTYwNzI5Ni8="><img src="http://phpprotip.com/wp-content/uploads/2011/10/6219607296_4b07a59460_z.jpg" alt="MySQL Workbench MAMP Connection Settings" width="640" height="562" /></a></div>
<p>After setting that up, I got to thinking, "I'm already using an IDE for code convenience and a GUI for <a class=\"zem_slink\" title=\"Internet Relay Chat\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9JbnRlcm5ldF9SZWxheV9DaGF0" rel=\"wikipedia nofollow\">vhost</a> convenience, I should set up Server Administration with MySQL Workbench too!" So after some googling, I found an article to help me <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NocmlzY2hhcmx0b24udXMvdGlwL3VzaW5nLW15c3FsLXdvcmtiZW5jaC1tYW1wLXBybw==">set up Server Administration with MAMP</a>. Unfortunately the article only got things partially working and has no way to comment on it to have it corrected. So I'm going to outline the steps. Also I just noticed that the images with the article are updated correctly but it's hard to cut and paste an image of something someone has done so I'll just give you the value pairs</p>
<ul>
<li>Configuration File: /Applications/MAMP/tmp/mysql/my.cnf</li>
<li>Start: /Applications/MAMP/bin/startMysql.sh -</li>
<li>Stop: /Applications/MAMP/bin/stopMysql.sh -</li>
<li>Check MySQL Status: ps -xa | <a class=\"zem_slink\" title=\"Grep\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9HcmVw" rel=\"wikipedia nofollow\">grep</a> "/Applications/MAMP/Library/bin/[m]ysqld"</li>
</ul>
<div>If the check status doesn't work, just do a</div>
<div>ps -xa | grep MAMP</div>
<div>and find the correct path to mysqld</div>
<div>And that's all you need to know.</div>
<div><a title=\"MySQL Workbench MAMP System Profile Settings Tab by chancegarcia, on Flickr\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5mbGlja3IuY29tL3Bob3Rvcy9jaGFuY2VnYXJjaWEvNjIxOTA4NTY4MS8="><img src="http://phpprotip.com/wp-content/uploads/2011/10/6219085681_cf951a37a6_z.jpg" alt="MySQL Workbench MAMP System Profile Settings Tab" width="640" height="569" /></a></div>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class=\"zemanta-pixie-a\" title=\"Enhanced by Zemanta\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy56ZW1hbnRhLmNvbS8="><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/zemified_c.png?x-id=6e393991-1345-4618-a1a2-eca170090c2c" alt="Enhanced by Zemanta" /></a></div>
 <img src="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=527" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://phpprotip.com/2011/10/using-mysql-workbench-with-mamp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>expected exceptions annotations, mocked object calls, oh my.</title>
		<link>http://phpprotip.com/2010/12/expected-exceptions-annotations-mocked-object-calls-oh-my/</link>
		<comments>http://phpprotip.com/2010/12/expected-exceptions-annotations-mocked-object-calls-oh-my/#comments</comments>
		<pubDate>Fri, 24 Dec 2010 15:06:11 +0000</pubDate>
		<dc:creator>chance</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpunit]]></category>
		<category><![CDATA[unittesting]]></category>
		<category><![CDATA[Exception handling]]></category>
		<category><![CDATA[Mock object]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://phpprotip.com/?p=490</guid>
		<description><![CDATA[Note: I have tested this in PHPUnit 3.4.1 and haven't tried it out in 3.5. Anyone who has worked with PHPUnit has most likely worked with expected exceptions and mock objects. The nice thing about working with expected exceptions is that we have access to a handy @expectedException annotation. I've gotten into the habit of [...]]]></description>
			<content:encoded><![CDATA[<p>Note: I have tested this in <a class=\"zem_slink freebase/en/phpunit\" title=\"PHPUnit\" rel=\"homepage nofollow\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHB1bml0LmRlLw==">PHPUnit</a> 3.4.1 and haven't tried it out in 3.5.<br />
Anyone who has worked with PHPUnit has most likely worked with expected <a class=\"zem_slink freebase/en/exception_handling\" title=\"Exception handling\" rel=\"wikipedia nofollow\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9FeGNlcHRpb25faGFuZGxpbmc=">exceptions</a> and mock objects. The nice thing about working  with expected exceptions is that we have access to a handy @expectedException annotation. I've gotten into the habit of using this for exceptions my fixtures should throw but also for when I'm using a <a class=\"zem_slink freebase/en/mock_object\" title=\"Mock object\" rel=\"wikipedia nofollow\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Nb2NrX29iamVjdA==">mock object</a> to verify a method call. So my tests usually expect foo_exception for fixture throws and when i'm testing method calls via a mock, they expect Exception. Therein lies my problem. Because all my custom class exceptions obviously extend the Exception class, I can get some false positives in testing.</p>
<pre class="php">equire_once <span style="color: #ff0000;">'Zend/Loader/Autoloader.php'</span>;
<span style="color: #0000ff;">$loader</span> = Zend_Loader_Autoloader::<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #b1b100;">require_once</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'foo.php'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #006699; font-weight: bold;">class</span> tmpTest <span style="color: #006699; font-weight: bold;">extends</span> PHPUnit_Framework_Testcase
<span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/**
     * @expectedException Exception
     */</span>
    <span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">function</span> testFooBar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0000ff;">$foo</span>=<span style="color: #006699; font-weight: bold;">new</span> foo<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #0000ff;">$foo</span>-&amp;gt;bar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/**
     * @expectedException Exception
     */</span>
    <span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">function</span> testBarBaz<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0000ff;">$mock</span>=<span style="color: #0000ff;">$this</span>-&amp;gt;getMock<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'foo'</span>,<a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L2FycmF5"><span style="color: #006666;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'baz'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #0000ff;">$mock</span>-&amp;gt;expects<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&amp;gt;any<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
         -&amp;gt;method<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'baz'</span><span style="color: #66cc66;">&#41;</span>
         -&amp;gt;will<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&amp;gt;throwException<span style="color: #66cc66;">&#40;</span><span style="color: #006699; font-weight: bold;">new</span> Exception<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'baz'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #0000ff;">$mock</span>-&amp;gt;barbaz<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>
<pre class="php"><span style="color: #006699; font-weight: bold;">class</span> foo_exception <span style="color: #006699; font-weight: bold;">extends</span> Exception<span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #006699; font-weight: bold;">class</span> foo
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">function</span> bar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        throw <span style="color: #006699; font-weight: bold;">new</span> foo_exception<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'bar'</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">function</span> baz<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L2VjaG8="><span style="color: #006666;">echo</span></a> <span style="color: #ff0000;">&quot;bwah<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">function</span> barbaz<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0000ff;">$this</span>-&amp;gt;bar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #0000ff;">$this</span>-&amp;gt;baz<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>
<p>So here we have an expectation for Exception but if we look at the code, we see that the bar method throws a foo_exception and the testBarBaz test is trying to test for the baz call via a mock that throws an Exception. if we change the annotation to expect foo_exception, the test still passes. This leads me to believe the best way to isolate the behavior we wish to test is to not use annotation for these sorts of tests. Or if you want to use annotation, be sure to use a unique exception for the mock. This means, unfortunately for me, that I'll have to go back through all my tests and ensure there's no false positives.</p>
<p>Lesson learned: be careful using shortcuts (and don't stand in the fire).</p>
<p>On a side note, <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cHM6Ly9naXRodWIuY29tL3NlYmFzdGlhbmJlcmdtYW5uL3BocHVuaXQvYmxvYi8zLjUvUEhQVW5pdC9GcmFtZXdvcmsvVGVzdENhc2UucGhwI0w3NDM=">this part of PHPUnit</a> is why those tests will behave that way. The behavior is completely my fault but I wanted to confirm it was behaving because of how it was verifying the expected exception.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class=\"zemanta-pixie-a\" title=\"Enhanced by Zemanta\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy56ZW1hbnRhLmNvbS8="><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/zemified_c.png?x-id=d53ab02f-d978-4960-8750-b7ee8c46327b" alt="Enhanced by Zemanta" /></a><span class="zem-script more-related more-info pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
 <img src="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=490" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://phpprotip.com/2010/12/expected-exceptions-annotations-mocked-object-calls-oh-my/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>fun with arrays and requirement chains</title>
		<link>http://phpprotip.com/2010/12/fun-with-arrays-and-requirement-chains/</link>
		<comments>http://phpprotip.com/2010/12/fun-with-arrays-and-requirement-chains/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 21:21:09 +0000</pubDate>
		<dc:creator>chance</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web dev]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://phpprotip.com/?p=484</guid>
		<description><![CDATA[Recently, I had to figure out if a given set of features contained all of their necessary requirements. For better or worse, the table was modeled so that the feature table referenced itself so that it could create a parent/child requirement chain. For example: feature_id requirement_id 2 null 5 2 7 null 11 5 So [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I had to figure out if a given set of features contained all of their necessary requirements.</p>
<p>For better or worse, the table was modeled so that the feature table referenced itself so that it could create a parent/child requirement chain. For example:</p>
<table>
<thead>
<tr>
<th>feature_id</th>
<th>requirement_id</th>
</tr>
</thead>
<tbody>
<tr>
<td>2</td>
<td>null</td>
</tr>
<tr>
<td>5</td>
<td>2</td>
</tr>
<tr>
<td>7</td>
<td>null</td>
</tr>
<tr>
<td>11</td>
<td>5</td>
</tr>
</tbody>
</table>
<p>So my problem is to find out if a given set of requested features, make sure that the requirements are also present. This includes any requirements the requirement feature may have. In this example, 11 requires 5 which requires 2.<br />
Let's take $featureRequest1=array(2,5,7,11) and $featureRequest2=array(7,5,11). If I were to run a look up of requirements, I would find that we have</p>
<pre class="php"><span style="color: #0000ff;">$requirements</span>=<a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L2FycmF5"><span style="color: #006666;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>.</pre>
<p>I tried to use the php in_array function but it didn't work as I expected it to.</p>
<pre class="php"><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L2luX2FycmF5"><span style="color: #006666;">in_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$requirements</span>,<span style="color: #0000ff;">$featureRequest1</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// i expect true</span>
<a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L3Zhcl9kdW1w"><span style="color: #006666;">var_dump</span></a><span style="color: #66cc66;">&#40;</span><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L2luX2FycmF5"><span style="color: #006666;">in_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$requirements</span>,<span style="color: #0000ff;">$featureRequest1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// false</span>
<a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L2luX2FycmF5"><span style="color: #006666;">in_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$requirements</span>,<span style="color: #0000ff;">$featureRequest2</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// i expect false</span>
<a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L3Zhcl9kdW1w"><span style="color: #006666;">var_dump</span></a><span style="color: #66cc66;">&#40;</span><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L2luX2FycmF5"><span style="color: #006666;">in_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$requirements</span>,<span style="color: #0000ff;">$featureRequest2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// false</span></pre>
<p>I then realized what I need is for there to be a clear intersection between the requirements and the request.</p>
<pre class="php"><span style="color: #0000ff;">$requirements</span>==<a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L2FycmF5X2ludGVyc2VjdA=="><span style="color: #006666;">array_intersect</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$requirements</span>,<span style="color: #0000ff;">$featureRequest1</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// expect true</span>
<a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L3Zhcl9kdW1w"><span style="color: #006666;">var_dump</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$requirements</span>==<a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L2FycmF5X2ludGVyc2VjdA=="><span style="color: #006666;">array_intersect</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$requirements</span>,<span style="color: #0000ff;">$featureRequest1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// true</span>
<span style="color: #0000ff;">$requirements</span>==<a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L2FycmF5X2ludGVyc2VjdA=="><span style="color: #006666;">array_intersect</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$requirements</span>,<span style="color: #0000ff;">$featureRequest2</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// expect false</span>
<a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L3Zhcl9kdW1w"><span style="color: #006666;">var_dump</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$requirements</span>==<a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0L2FycmF5X2ludGVyc2VjdA=="><span style="color: #006666;">array_intersect</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$requirements</span>,<span style="color: #0000ff;">$featureRequest2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// false</span></pre>
<p>I should probably note that array_interest will preserve the array keys. To fix it, you can either flip the 2 arguments or pass the return array to array_values</p>
 <img src="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=484" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://phpprotip.com/2010/12/fun-with-arrays-and-requirement-chains/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Meet the PHP Dev Derby Team</title>
		<link>http://phpprotip.com/2010/09/meet-the-php-dev-derby-team/</link>
		<comments>http://phpprotip.com/2010/09/meet-the-php-dev-derby-team/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 14:45:57 +0000</pubDate>
		<dc:creator>chance</dc:creator>
				<category><![CDATA[dev derby]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[the combine]]></category>

		<guid isPermaLink="false">http://phpprotip.com/?p=469</guid>
		<description><![CDATA[I liked how the Dev Derby website did team leader profiles and decided to try to do something similar. No one provided any pictures but most did answer some questions I asked so without much further ado, meet the PHP Dev Derby Team. The team consists of Dennis Rogers (@_drogers) Max Beatty (@maxbeatty) Matthew Haralovich [...]]]></description>
			<content:encoded><![CDATA[<p>I liked how the <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2RldmRlcmJ5LmNvbQ==">Dev Derby</a> website did team leader profiles and decided to try to do something similar. No one provided any pictures but most did answer some questions I asked so without much further ado, meet the <a class=\"zem_slink freebase/en/php\" title=\"PHP\" rel=\"homepage\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0Lw==">PHP</a> Dev Derby Team.</p>
<p>The team consists of</p>
<ul>
<li>Dennis Rogers (@_drogers)</li>
<li>Max Beatty (@maxbeatty)</li>
<li>Matthew Haralovich (aka zon)</li>
<li>Grant Simpson (@grantls)</li>
<li>Ryan Dagey (@dageytech)</li>
</ul>
<p>Update: added in Ryan Dagey's answers. And photo.</p>
<p><span id="more-469"></span></p>
<h3>Meet Dennis Rogers (@_drogers)</h3>
<h4>What do you like about PHP?</h4>
<p>It's what I know, and free.</p>
<h4>What book,movie or album do you think best embodies your personality?</h4>
<p>Anchorman</p>
<h4>What is your biggest pet peeve?</h4>
<p>The expression "pet peeve"</p>
<h4>What inspires you?</h4>
<p>Power Ballads.</p>
<h4>2 or 3 favorite quotes, sayings, etc. (e.g. "If you want to achieve greatness, stop asking for permission")</h4>
<p>"that's a bold statement"</p>
<h3>Meet Max Beatty (@maxbeatty)</h3>
<h4>What do you like about PHP?</h4>
<p>I like PHP because it gets the job done. You can do what you need to do with it.</p>
<h4>What book,movie or album do you think best embodies your personality?</h4>
<p>I've recently drawn some eerily similarities between myself and <a class=\"zem_slink\" title=\"Tony Hsieh\" rel=\"twitter\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3R3aXR0ZXIuY29tL3phcHBvcw==">Tony Hsieh</a> in his book <a class=\"zem_slink\" title=\"Delivering Happiness: A Path to Profits, Passion, and Purpose\" rel=\"amazon\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5hbWF6b24uY29tL0RlbGl2ZXJpbmctSGFwcGluZXNzLVByb2ZpdHMtUGFzc2lvbi1QdXJwb3NlL2RwLzA0NDY1NjMwNDglM0ZTdWJzY3JpcHRpb25JZCUzRDBHODFDNURBWjAzWlI5V0g5WDgyJTI2dGFnJTNEemVtYW50YS0yMCUyNmxpbmtDb2RlJTNEeG0yJTI2Y2FtcCUzRDIwMjUlMjZjcmVhdGl2ZSUzRDE2NTk1MyUyNmNyZWF0aXZlQVNJTiUzRDA0NDY1NjMwNDg=">Delivering Happiness</a>, but <a class=\"zem_slink freebase/en/mark_hoppus\" title=\"Mark Hoppus\" rel=\"homepage\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5oaW15bmFtZWlzbWFyay5jb20v">Mark Hoppus</a> wouldn't be a bad comparison - easy going, fun loving, knows his stuff at the end of the day.</p>
<h4>What is your biggest pet peeve?</h4>
<p>Making things harder and more complex than they need to be.</p>
<h4>What inspires you?</h4>
<p>Simplicity. Anything that has everything it needs and nothing more.</p>
<h4>2 or 3 favorite quotes, sayings, etc. (e.g. "If you want to achieve greatness, stop asking for permission")</h4>
<p>"There is no such thing as information overload, just bad design. If something is cluttered and confusing, fix your design". - <a class=\"zem_slink freebase/en/edward_tufte\" title=\"Edward Tufte\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9FZHdhcmRfVHVmdGU=">Edward Tufte</a></p>
<p>"You can here because we do this better than you, and part of that is letting our creatives be unproductive until they are." - Don Draper</p>
<h3><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3BocHByb3RpcC5jb20vd3AtY29udGVudC91cGxvYWRzLzIwMTAvMDkvcnlhbl9oYXQuanBn"><img class="alignleft size-medium wp-image-480" title="ryan_hat" src="http://phpprotip.com/wp-content/uploads/2010/09/ryan_hat-215x300.jpg" alt="" width="215" height="300" /></a>Meet Ryan Dagey</h3>
<h4>What do you like about PHP?</h4>
<p>Coming from a C[++] background, I found PHP easy to pick up.  Outside of VBScript, PHP was my first formal scripting language, so I appreciated how quickly I could develop a script to do what I needed, compared to compile&amp;  debugging.<br />
Another favorite PHP feature of mine is easy integration into web frameworks, even when using <a class=\"zem_slink freebase/en/object-oriented_programming\" title=\"Object-oriented programming\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9PYmplY3Qtb3JpZW50ZWRfcHJvZ3JhbW1pbmc=">object-oriented</a>.  Compared with C#,PHP makes accomplishing the simplest and complex tasks as natural as writing pseudo-code.</p>
<div>
<h4>What book,movie or album do you think best embodies your personality?</h4>
</div>
<p>"The Usual Suspects"</p>
<h4>What is your biggest pet peeve?</h4>
<p>People's pet peeves, I take people as they are, very much a laid back go with the flow, laissez-faire attitude guy</p>
<h4>What inspires you?</h4>
<p>I'm inspired by those who achieve the impossible,  learning about great feats of science and the unyielding quest for  answers.</p>
<div>
<h4>2 or 3 favorite quotes, sayings, etc. (e.g. "If you want to achieve greatness, stop asking for permission")</h4>
</div>
<p>Do or do not, there is no try -Yoda<br />
Courage is not the absence of fear, but the mastery of fear -Samuel Clemens</p>
<h6 class="zemanta-related-title" style="font-size: 1em;">Related articles by Zemanta</h6>
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3BocHByb3RpcC5jb20vMjAxMC8wNy9kZXYtZGVyYnkv">Dev Derby</a> (phpprotip.com)</li>
</ul>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class=\"zemanta-pixie-a\" title=\"Enhanced by Zemanta\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy56ZW1hbnRhLmNvbS8="><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/zemified_c.png?x-id=9479fd34-f924-4e53-ac0a-258d421ffb0c" alt="Enhanced by Zemanta" /></a><span class="zem-script more-related more-info pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
 <img src="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=469" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://phpprotip.com/2010/09/meet-the-php-dev-derby-team/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Call to Arms</title>
		<link>http://phpprotip.com/2010/08/call-to-arms/</link>
		<comments>http://phpprotip.com/2010/08/call-to-arms/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 18:15:08 +0000</pubDate>
		<dc:creator>chance</dc:creator>
				<category><![CDATA[dev derby]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[the combine]]></category>
		<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Bloomington Indiana]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Startup Weekend]]></category>

		<guid isPermaLink="false">http://phpprotip.com/?p=458</guid>
		<description><![CDATA[Image via Wikipedia How much code can you generate in a day? We are actively recruiting participants to take place in a developer event ("Dev Derby") that pits one language against others. It is a day-long programming challenge where teams of developers work to create an application serving a real-world need. Five teams will represent [...]]]></description>
			<content:encoded><![CDATA[<div class="zemanta-img" style="margin: 1em; display: block;">
<div>
<dl class="wp-caption alignright" style="width: 310px;">
<dt class="wp-caption-dt"><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvbW1vbnMud2lraXBlZGlhLm9yZy93aWtpL0ZpbGU6UHJvZ3JhbW1pbmdfbGFuZ3VhZ2VfdGV4dGJvb2tzLmpwZw=="><img title="A selection of programming language textbooks ..." src="http://phpprotip.com/wp-content/uploads/2010/08/300px-Programming_language_textbooks.jpg" alt="A selection of programming language textbooks ..." width="300" height="204" /></a></dt>
<dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;">Image via <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvbW1vbnMud2lraXBlZGlhLm9yZy93aWtpL0ZpbGU6UHJvZ3JhbW1pbmdfbGFuZ3VhZ2VfdGV4dGJvb2tzLmpwZw==">Wikipedia</a></dd>
</dl>
</div>
</div>
<h3>How much code can you generate in a day?</h3>
<p>We are actively recruiting participants to take place in a developer event ("<a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2RldmRlcmJ5LmNvbS9hcHBsaWNhdGlvbi8=">Dev Derby</a>") that pits one language against others. It is a day-long <a class=\"zem_slink freebase/en/computer_programming\" title=\"Computer programming\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Db21wdXRlcl9wcm9ncmFtbWluZw==">programming</a> challenge where teams of developers work to create an application serving a real-world need. Five teams will represent different programming languages—<a class=\"zem_slink freebase/en/php\" title=\"PHP\" rel=\"homepage\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0Lw==">PHP</a>, C#, Ruby, <a class=\"zem_slink freebase/en/coldfusion\" title=\"ColdFusion\" rel=\"homepage\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5hZG9iZS5jb20vcHJvZHVjdHMvY29sZGZ1c2lvbg==">ColdFusion</a>, and <a class=\"zem_slink freebase/guid/9202a8c04000641f800000000f8545aa\" title=\"Java (programming language)\" rel=\"homepage\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2phdmEuc3VuLmNvbQ==">Java</a>—to produce a demo application that will be released as <a class=\"zem_slink freebase/en/open_source\" title=\"Open Source\" rel=\"wikinvest\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy53aWtpbnZlc3QuY29tL2NvbmNlcHQvT3Blbl9Tb3VyY2U=">open source</a> software.</p>
<p><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2RldmRlcmJ5LmNvbS9hcHBsaWNhdGlvbi8=">http://devderby.com/application/</a></p>
<p>Team Leaders for each language will review applications and select competitively balanced squads. There is no cost to enter, but spots on teams are limited. Winning teams can win prizes and all participants are eligible for discounts to other tech events taking place that week.</p>
<p>The Dev Derby will start and end on Saturday, September 11, 2010, in Bloomington, Indiana. It is part of <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RoZWNvbWJpbmUub3Jn">The Combine (http://thecombine.org)</a>, the area’s first major <a class=\"zem_slink freebase/en/technology\" title=\"Technology\" rel=\"wikinvest\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy53aWtpbnZlc3QuY29tL2luZHVzdHJ5L1RlY2hub2xvZ3k=">technology</a> conference, and at the start of the <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2JmbGV4LmluZm8=">BFusion/BFlex conference (http://bflex.info)</a>. Dev Derby involves an intense six-hour coding session.</p>
<p>Each challenge submission will be judged by knowledge leaders and representatives of the <a class=\"zem_slink freebase/en/not-for-profit_corporation\" title=\"Non-profit organization\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Ob24tcHJvZml0X29yZ2FuaXphdGlvbg==">non-profit organizations</a> benefiting from this work. The criteria spans Design (features and UI choices made), Technical Efficiency (code and performance), Communication (documentation and presentation), and Practical Value (use, adoption, and maintenance).</p>
<p>Prizes will be awarded at the end of the day, following a panel discussion about the development process and the future of application programming.</p>
<p><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2RldmRlcmJ5LmNvbS9hcHBsaWNhdGlvbi8=">Dev Derby</a> is situated in The Combine along with other technology-related events, such as Tech Cocktail, Ignite Bloomington, and a variety of of other gatherings. It is hosted by the BFusion/BFlex conference, a two-day hands-on training event from the experts of <a class=\"zem_slink freebase/en/adobe_flex\" title=\"Adobe Flex\" rel=\"homepage\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5hZG9iZS5jb20vZ28vZmxleC8=">Adobe Flex</a> and ColdFusion. Dev Derby is inspired by our experience with <a class=\"zem_slink\" title=\"Startup Weekend\" rel=\"homepage\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zdGFydHVwd2Vla2VuZC5vcmc=">Startup Weekend</a> in 2008, but with a short day of coding and focused on a specific challenge.</p>
<p>Apply now: <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2RldmRlcmJ5LmNvbS9hcHBsaWNhdGlvbi8=">http://devderby.com/application/</a></p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class=\"zemanta-pixie-a\" title=\"Enhanced by Zemanta\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy56ZW1hbnRhLmNvbS8="><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/zemified_c.png?x-id=d4302942-9752-4c08-9e57-3e6bd174a770" alt="Enhanced by Zemanta" /></a><span class="zem-script more-related more-info pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
 <img src="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=458" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://phpprotip.com/2010/08/call-to-arms/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Valuable Professional Reading</title>
		<link>http://phpprotip.com/2010/08/valuable-professional-reading/</link>
		<comments>http://phpprotip.com/2010/08/valuable-professional-reading/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 19:12:38 +0000</pubDate>
		<dc:creator>chance</dc:creator>
				<category><![CDATA[dev derby]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[the combine]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://phpprotip.com/?p=451</guid>
		<description><![CDATA[Image via Wikipedia The team leaders for Dev Derby have been asked to list what we consider valuable professional reading. Our book selections are not limited to our respective Languages. I thought I would share my list with everyone. The first 2 (GoF design patterns and Patterns of enterprise application architecture) really just need to [...]]]></description>
			<content:encoded><![CDATA[<div class="zemanta-img" style="margin: 1em; display: block;">
<div>
<dl class="wp-caption alignright" style="width: 310px;">
<dt class="wp-caption-dt"><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9GaWxlOlRoZV9wcmFnbWF0aWNfcHJvZ3JhbW1lci5qcGc="><img title="book cover" src="http://phpprotip.com/wp-content/uploads/2010/08/300px-The_pragmatic_programmer.jpg" alt="book cover" width="300" height="377" /></a></dt>
<dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;">Image via <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9GaWxlOlRoZV9wcmFnbWF0aWNfcHJvZ3JhbW1lci5qcGc=">Wikipedia</a></dd>
</dl>
</div>
</div>
<p>The team leaders for <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RoZWNvbWJpbmUub3Jn">Dev Derby</a> have been asked to list what we consider valuable professional reading. Our book selections are not limited to our respective Languages. I thought I would share my list with everyone.</p>
<p>The first 2 (GoF design patterns and Patterns of enterprise  application architecture) really just need to be in every developer's  library. The rest are a collections of books I've read and liked as well  as recommendations from developers I like and respect. <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Nhc2V5c29mdHdhcmUuY29tL2Jsb2c=">Keith Casey</a> pointed me in the general direction of a lot of these books.I suspect that some of the <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RoZWNvbWJpbmUub3JnLw==">Dev Derby</a> people will end up contacting various publishers to solicit swag  sometime soon.</p>
<p>In other news about Dev Derby, I think that an  application for teams should be available to announce sometime soon. I  do know we have a deadline for selection approaching and it's kinda hard  to select without people to select from.</p>
<p>GoF <a class=\"zem_slink freebase/en/design_pattern\" title=\"Design pattern (computer science)\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9EZXNpZ25fcGF0dGVybl8lMjhjb21wdXRlcl9zY2llbmNlJTI5">design patterns</a>:<br />
* <a class=\"zem_slink freebase/en/international_standard_book_number\" title=\"International Standard Book Number\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9JbnRlcm5hdGlvbmFsX1N0YW5kYXJkX0Jvb2tfTnVtYmVy">ISBN</a>-10: 0201633612<br />
* ISBN-13: 978-020163361</p>
<p>Patterns of enterprise application architecture:<br />
* ISBN-10: 0321127420<br />
* ISBN-13: 978-0321127426<br />
<span id="more-451"></span><br />
Code Reading:<br />
* ISBN-10: 0201799405<br />
* ISBN-13: 978-0201799408</p>
<p>Guide to <a class=\"zem_slink freebase/en/php\" title=\"PHP\" rel=\"homepage\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5waHAubmV0Lw==">PHP</a> Design Patterns:<br />
* ISBN-10: 0973589825<br />
* ISBN-13: 978-0973589825</p>
<p>Building Scalable Web Sites:<br />
* ISBN-10: 0596102356<br />
* ISBN-13: 978-0596102357</p>
<p>Peopleware:<br />
* ISBN-10: 0932633439<br />
* ISBN-13: 978-0932633439</p>
<p>Mythical Man Month:<br />
* ISBN-10: 0201835959<br />
* ISBN-13: 978-0201835953</p>
<p>The Pragmatic Programmer:<br />
* ISBN-10: 020161622X<br />
* ISBN-13: 978-0201616224</p>
<p>Code Complete:<br />
* ISBN-10: 0735619670<br />
* ISBN-13: 978-0735619678</p>
<p>Zend PHP 5 Certification Study Guide:<br />
* ISBN-10: 0973862149<br />
* ISBN-13: 978-0973862140</p>
<p>Guide to PHP Security:<br />
* ISBN-10: 0973862106<br />
* ISBN-13: 978-0973862102</p>
<p>Guide to Enterprise PHP Development:<br />
* ISBN-10: 0973862181<br />
* ISBN-13: 978-0973862188</p>
<p>Guide to Programming with <a class=\"zem_slink freebase/en/zend_framework\" title=\"Zend Framework\" rel=\"homepage\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2ZyYW1ld29yay56ZW5kLmNvbS8=">Zend Framework</a><br />
* ISBN-10: 0973862157<br />
* ISBN-13: 978-0973862157</p>
<h6 class="zemanta-related-title" style="font-size: 1em;">Related articles by Zemanta</h6>
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3BocHByb3RpcC5jb20vMjAxMC8wNy9kZXYtZGVyYnkv">Dev Derby</a> (phpprotip.com)</li>
</ul>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class=\"zemanta-pixie-a\" title=\"Enhanced by Zemanta\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy56ZW1hbnRhLmNvbS8="><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/zemified_c.png?x-id=4817d827-1e10-477b-9a42-d7ff15fce267" alt="Enhanced by Zemanta" /></a><span class="zem-script more-related more-info pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
 <img src="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=451" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://phpprotip.com/2010/08/valuable-professional-reading/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Auth/ACL implementation strategies</title>
		<link>http://phpprotip.com/2010/08/authacl-implementation-strategies/</link>
		<comments>http://phpprotip.com/2010/08/authacl-implementation-strategies/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 18:52:21 +0000</pubDate>
		<dc:creator>chance</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[theory crafting]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[Access control list]]></category>
		<category><![CDATA[ACL]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://phpprotip.com/?p=384</guid>
		<description><![CDATA[I'm going to talk more about ACLs than Auth. Auth is simple, it's the ACL that will trip you up.  Since both concepts are coupled together when you're making a login system, I feel it's appropriate to at least touch on Auth. What I want to cover is the ways we can create the ACL [...]]]></description>
			<content:encoded><![CDATA[<p>I'm going to talk more about <a class=\"zem_slink freebase/en/access_control_list\" title=\"Access control list\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9BY2Nlc3NfY29udHJvbF9saXN0">ACLs</a> than Auth. Auth is simple, it's the ACL that will trip you up.  Since both concepts are coupled together when you're making a login system, I feel it's appropriate to at least touch on Auth. What I want to cover is the ways we can create the ACL object to suit needs based on the scale of the project. I'm going to assume that readers have a passing familiarity with using the Auth and Acl objects and may have even implemented them into projects.</p>
<h2><span id="more-384"></span>Zend_Auth</h2>
<p>The reason I say Auth is simple is because <a class=\"zem_slink freebase/en/zend_framework\" title=\"Zend Framework\" rel=\"homepage\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2ZyYW1ld29yay56ZW5kLmNvbS8=">Zend Framework</a> makes it simple with their <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2ZyYW1ld29yay56ZW5kLmNvbS9tYW51YWwvZW4vemVuZC5hdXRoLmh0bWw=">Zend_Auth</a> class. You can pick an auth style, implement and then go from there. For the purpose of this discussion, I'll be talking using Database authentication. So after one has set up a login page that uses Zend_Auth (there are already a lot of articles that cover this so i'll move on), the major bear you have to tackle is using the Zend_Auth_Result to determine proper access. Sounds simple, that's what Zend_Acl is for.</p>
<h2>Zend_Acl</h2>
<p>So how do we create our Acl? Again, ZF's reference guide gives us some handy-dandy examples of using their object but how you utilize the object depends on your scale. Other articles give you a way to bind the two together, usually via a controller plugin of some sort. The thing that can be tricky is how you want the Acl and Auth to interact with each other within that plugin. I utilize a controller plugin that fires off an Auth/Acl check in the dispatchLoopStartup() method. If no Zend_Auth_Result object exists, it assigns a guest role and if one does exist, it searches the Zend_Auth_Storage for a role value (assigning guest if one doesn't exist somehow) and checks that value against the Acl that was created in my Bootstrap. My biggest conundrum has always been translating Requests into Resources. I'll talk more on that later.</p>
<h2>Scaling</h2>
<p>I tend to put my scaling into one of the following categories: small,decent or ZOMG. Small is something like a personal site or a proof-of-concept/self-tutorial project where my users will probably be a 1-5 roles and 1-5 resources at best. Decent is most collaborative niche projects with 50-100 resources. ZOMG is where the number of resources I'm dealing with is &gt;100, unknown or potentially large. I define my ACLs in my Bootstrap in one of three ways:</p>
<ol>
<li><a class=\"zem_slink freebase/en/hard_code\" title=\"Hard coding\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9IYXJkX2NvZGluZw==">Hardcoded</a></li>
<li>As part of my Navigation Object properties</li>
<li>Pulled from a <a class=\"zem_slink freebase/en/database\" title=\"Database\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9EYXRhYmFzZQ==">database</a></li>
</ol>
<h3>Hardcoded</h3>
<p>This one is easy to implement since if you follow the ZF reference or the <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy56aW11ZWwuaXQvYmxvZy8/cD04Ng==">numerous</a> guides/posts you find when you <a class=\"zem_slink freebase/en/google\" title=\"Google\" rel=\"homepage\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2dvb2dsZS5jb20=">google</a> for auth/acl systems, you'll be able to hardcode your ACL. I find this ideal for small projects where the number of resources is relatively low and the growth of adding additional resources is non-existent. This is the simplest way to do things.</p>
<h3>Navigation-based</h3>
<p>This method makes use of the Zend_Navigation object. <a class=\"zem_slink\" title=\"Brandon Savage\" rel=\"blog\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5icmFuZG9uc2F2YWdlLm5ldC8=">Brandon Savage</a> wrote up a nice <a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5icmFuZG9uc2F2YWdlLm5ldC9jb250cm9sbGluZy1hY2Nlc3MtemVuZF9uYXZpZ2F0aW9uLWFuZC16ZW5kX2FjbC8=">guide to integrating ACLs into you r Navigation</a>. I usually instantiate my Navigation objects in the Bootstrap from a <a class=\"zem_slink freebase/en/extensible_markup_language\" title=\"XML\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9YTUw=">XML</a> file. The only tricky thing I found with this is finding the appropriate Navigation_Page (that tells us our resource/permissions) from the Request object. I tend to utilize this method when the growth of resources occurs at a slow pace.</p>
<h3>Database-driven</h3>
<p>This particular method is what spurred me to write about Auth and Acl. I see this solution as ideal for a high amount of resources or where the growth of resources to have fast spurts.  This solution can allow for ease of maintenance and is <a class=\"zem_slink freebase/en/scalability\" title=\"Scalability\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9TY2FsYWJpbGl0eQ==">scalable</a>. Even though it is a scalable solution, I kind of see it as overkill for smaller, low-growth projects.</p>
<h2>Multiple project ACLs</h2>
<p>Since I've began working with Zend Framework, I have used it to create both internal apps in addition to running my company's main site. To date, I have a total of eleven internal applications, some of which require Auth/Acl and some of which do not. Those that do not require them will soon be requiring them due to future features we wish to implement for them. At first I was working on a <a class=\"zem_slink freebase/en/drag-and-drop\" title=\"Drag-and-drop\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9EcmFnLWFuZC1kcm9w">drag and drop</a> solution for setting up an Auth/ACL system for any given project. I was going to work it a stand-alone module where all the developer has to do is call the Module Bootstrap within the Application Bootstrap. The drag and drop solution was going to rely on the project's Navigation object for determining the ACL of a requested page. Then it occurred to me that even if I could make this 'simple' drag and drop solution, we'd be faced with reapplying it to ten more projects and have subsequent setup processes for each additional project. This seemed highly inefficient and a pain in my ass.</p>
<h3>Control Panel</h3>
<p>My next realization was that there was multiple overlap on the users accessing various internal applications and way too many vhosts to make for each project. It seemed like it would be better to do the ultimate refactor and create a centralized control panel for people to authenticate and access internal applications.</p>
<p>I was still hung up on wanting to reuse my Navigation based code when I figured out that maintaining the navigation XML would be another nightmare. I had attempted a database solution for one project and it became a pain to maintain the ACL when I introduced Routing to the project. It was a bitter and hateful experience to get it working and since both the Auth/ACL and Routing parts of the project were done before I had embraced <a class=\"zem_slink freebase/en/unit_test\" title=\"Unit testing\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Vbml0X3Rlc3Rpbmc=">unit testing</a>, sorting through my crazy <a class=\"zem_slink freebase/en/monkey-patch\" title=\"Monkey patch\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Nb25rZXlfcGF0Y2g=">monkey patching</a> logic would only intensify my rage. I also recalled that the biggest issue with that proto-solution was translating the Request into a Resource.</p>
<p><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3BocHByb3RpcC5jb20vd3AtY29udGVudC91cGxvYWRzLzIwMTAvMDgvZGFzaGJvYXJkX3RhYmxlcy5wbmc="><img class="alignright size-medium wp-image-442" title="jank_acl_schema" src="http://phpprotip.com/wp-content/uploads/2010/08/dashboard_tables-300x176.png" alt="" width="300" height="176" /></a>In the schema shown on the right, the Resource.Name corresponded to the Request's Controller and Privilege.Name corresponded to Request's Action. When the ACL was created in the Bootstrap, it would create Module.Name_Resource.Name as the resource then associate privileges to that resource. Routing and Controller forwarding made this whole thing hard to mentally track. I ended up having a lot of monkey patch entries to make it work in the end.</p>
<p>So here I was, just generally damned when I thought up a way around the issues I had with the previous schema. I would need to have the Resource.Name independent of the Request <a class=\"zem_slink freebase/en/uniform_resource_identifier\" title=\"Uniform Resource Identifier\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Vbmlmb3JtX1Jlc291cmNlX0lkZW50aWZpZXI=">URI</a> in order to avoid routing issues. By associating the Resource to a URI, I don't have to account for if Routing exists or not. The URI will always be available and the core ACL system will be independent of any Routes that do/don't/might exist. Privileges bound to action seemed like a lot of overkill since all privileges come down to <a class=\"zem_slink freebase/en/crud\" title=\"Create, read, update and delete\" rel=\"wikipedia\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9DcmVhdGUlMkNfcmVhZCUyQ191cGRhdGVfYW5kX2RlbGV0ZQ==">CRUD</a> (though I always like the BREAD acronym better). In addition, privileges would be off in their own world and reused when necessary (the last schema had too many redundant privileges associated to different resources).</p>
<p><a href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3BocHByb3RpcC5jb20vd3AtY29udGVudC91cGxvYWRzLzIwMTAvMDgvY29udHJvbF9wYW5lbF9zY2hlbWEucG5n"><img class="alignright size-medium wp-image-440" title="control_panel_schema" src="http://phpprotip.com/wp-content/uploads/2010/08/control_panel_schema-272x300.png" alt="" width="272" height="300" /></a>As I stated earlier, the goal is a unified login for internal apps (there are currently eleven and this number will grow). The user table consists of a username, password and control panel role. This role allows for future interfaces to be built that can manage the control panel such as adding a project or adding users. If you're wondering why I have the password column as able to be null, it's to support some legacy items. Next major table is the project table which lets me have a project_user table  that is also has a role associated with it. I made role a separate table since a lot of the projects overlap on roles such as guest and admin. Resources can be specifically named or generalized as necessary. All my links (URIs) can share a resource name if necessary. Finally there is the privilege table along with a resource_privilege table that allows me to maintain those relationships. While I have a separate control_panel_role, I decided that the control panel resource/privilege system doesn't need to be separate. I only wanted to make sure that the control panel system was accessible even if there was no projects available for selection. I'm planning on making the past projects into modules under this system and all future internal apps accessible/controlled from here. I lack any co-workers that I'm able to debate the merits of this idea with and given that this will be a major refactor of my work thus far, I am asking for feedback on the idea. Am I missing any other viable ways of defining the ACL that would be easier/better? I'm not a DBA so I'm wondering if my tables are actually optimized well enough. Any other issues or thoughts I haven't considered?</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class=\"zemanta-pixie-a\" title=\"Enhanced by Zemanta\" href="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy56ZW1hbnRhLmNvbS8="><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/zemified_c.png?x-id=c137486e-8012-4ac3-8089-0392bb540ad6" alt="Enhanced by Zemanta" /></a><span class="zem-script more-related more-info pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
 <img src="http://phpprotip.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=384" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://phpprotip.com/2010/08/authacl-implementation-strategies/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

