<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Planet PHP</title><link rel="alternate" type="text/html" href="http://www.planet-php.net/"/><link rel="self" type="text/html" href="http://www.planet-php.net/atom/"/><subtitle>People blogging about PHP</subtitle><id>http://www.planet-php.net/</id><generator uri="http://planet-php.net/">
            Planet PHP Aggregator
            </generator><updated>2013-05-20T16:00:00Z</updated><link rel="hub" href="http://pubsubhubbub.appspot.com"/><entry><title type="text">Dear Ed (A response to Open Sourcing Mental Illness at php[tek] 2013)</title><link rel="alternate" type="text/html" href="http://daveyshafik.com/archives/65721-dear-ed-a-response-to-open-sourcing-mental-illness-at-phptek-2013.html" title="Dear Ed (A response to Open Sourcing Mental Illness at php[tek] 2013)"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~o2v" title="Shortlink to http://daveyshafik.com/archives/65721-dear-ed-a-response-to-open-sourcing-mental-illness-at-phptek-2013.html"/><author><name>Davey Shafik</name></author><id>http://daveyshafik.com/?p=65721</id><updated>2013-05-20T16:00:00Z</updated><published>2013-05-20T16:00:00Z</published><content type="html"><![CDATA[<blockquote><p>
  <strong>Note:</strong> this post is personal, and may contain triggers for those suffering through grief. Due to it’s nature, I did pass it by Ed before posting it publicly, as every body is different when dealing with their mental illnesses, and this is such a complex topic that it’s difficult to talk about without drawing broad brush strokes that may offend some people. Please keep in mind that this is [some of] <em>my</em> thoughts on this very complicated subject, and you are free to disagree.
</p></blockquote>
<p>Dear Ed,</p>
<p>I felt that I needed to write this letter to you, and I wanted it to be open because I think it’s an appropriate way to participate in open sourcing mental illness. Consider this a pull request of sorts. The only way to remove the stigma around this topic is by talking frankly and <strong>openly</strong> about it.</p>
<p>I’m writing this (specifically) in response to <a href="http://funkatron.com/posts/open-sourcing-mental-illness-at-php_tek13.html">the talk you gave</a> at <a href="http://tek.phparch.com">php[tek]</a> last week. I remember first meeting you, at php|tek (as it was then known) in Chicago, sometime around 2003-4, one of my first conferences. You had some local friends meeting you there and we all hung out at the hotel bar. It was fun. But I remember the <em>intimidation</em> of meeting this hard core rock looking dude that I didn’t think I could possibly fit in with and relate to.</p>
<p>I was expecting to find a rough biker type dude, that would beat me up if I said the wrong thing… And I remember you were very intense (which I now know was passion) and I remember the change that came over your entire demeanor when you started talking about your son… The warmth and joy that I saw made me think “holy crap, this guy is just an awesome dad. I like this guy!”. Someone else has described this phenomenon as you turning into a pile of goo. As a fairly new father myself I now understand that so much better — thanks for being one of my first peer role models for being a father.</p>
<p>I don’t suffer from the kinds of mental illness you (we?) are trying to help, I have some very irrational (but “normal”) fears – needles and bugs, especially wasps and spiders – and travel stresses me out (<a href="http://tripit.com">TripIt Pro</a> is so fantastic for helping me with that, ask me if you want details <img src='http://daveyshafik.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>I do however have experience with depression, and related things. I lost my father at age 11, and I lost my (first) wife at 22. These were traumatic, depressive, insane things to go through.</p>
<p>But I did get through them, and I feel stronger and happier at this end of that path. Thanks to folks like Ligaya Turmelle, Joey Smith, Matthew Turland and all three Elizabeths (Smith, Naramore and Tucker-Long), who have all at one time or another been a shoulder for me, I am now in a place where I can be laid back about most issues that many people simply can’t (the things that stress you out and cause anxiety on a daily basis). I live by “It is what it is”. But most folks can’t do that.</p>
<p>It is very difficult for me to relate to what people suffering from mental illness have been through in a lot of ways. The kinds of things I suffered from are considered “normal”, a part of the grieving process, and a temporary state; I personally don’t see it as the same thing as clinical depression — though they can lead to it — but “in the moment” they possibly are very similar.</p>
<p>I do however live with mental illness everyday day. My wife is bipolar (diagnosed and treated for about 6 years) and suffers from depression and anxieties. I see how it affects her, even with medication, and I really appreciate some more insight into a lot of things that she (like most people) has trouble verbalizing, so that I can help her handle it.</p>
<p>I don’t think I can help people suffering directly, I have no direct experience to draw from, other than my experiences with grief over a lost loved one… but I’m very open to any question about what I went through, and how I dealt with it from anyone <em>(consider that an open invitation to anyone reading this.)</em> But I wanted to let you know you have my support, admiration, and maybe even a little bit of love (OK a lot: internet hugs!) for opening yourself up to help this community we both hold so near and dear.</p>
<p>So, thank you!</p>
<ul>
<li>Davey</li>
</ul>
]]></content></entry><entry><title type="text">Survived php tek 2013</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dragonbe-php/~3/3oE_G4Pmuho/survived-php-tek-2013.html" title="Survived php tek 2013"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~o2m" title="Shortlink to http://feedproxy.google.com/~r/dragonbe-php/~3/3oE_G4Pmuho/survived-php-tek-2013.html"/><author><name>Michelangelo van Dam</name></author><id>http://www.dragonbe.com/2013/05/survived-php-tek-2013.html</id><updated>2013-05-20T12:14:00Z</updated><published>2013-05-20T12:14:00Z</published><content type="html"><![CDATA[<a href="https://twitter.com/CaseySoftware/status/335192997983555584/photo/1" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="112" src="http://1.bp.blogspot.com/-DZ6tgyZSHRw/UZoBfcvrm0I/AAAAAAAADxk/Sv6pwwXRMQw/s200/BKbYQXhCEAArUQm.jpg-large.jpeg" width="200"/></a>If you were last week in Chicago, you've might felt the city was buzzing <a href="http://php.net/">PHP</a> all over the place. <a href="http://tek.phparch.com/">php[tek] 2013</a> was taking place at the <a href="http://www.sheratonchicagoohare.com/">Sheraton Gateway Suites Chicago O'Hare</a> in Rosemont, just outside of Chicago city.<br/><br/>This year it was also the first time <a href="http://musketeers.me/">Musketeers.me</a>, a php consulting team from the East Coast, was running the show, putting their own signature onto the event. And with great success I might add. A well deserved applause to <a href="https://twitter.com/kevinbruce">Eli White</a>, <a href="https://twitter.com/kevinbruce">Kevin Bruce</a>, <a href="https://twitter.com/sandys1">Sandy Smith</a>, <a href="https://twitter.com/omerida">Oscar Merida</a> and of course the <a href="https://twitter.com/e3betht">Beth Tucker Long</a> for their unlocked achievement running a great conference.<br/><br/>For me was also the first time I was running the uncon, where attendees and conference speakers could propose talks they wanted to present at the uncon and have other attendees vote for them.<br/><br/>One uncon talk really stood out: "<a href="https://speakerdeck.com/funkatron/open-sourcing-mental-illness">Open Sourcing mental illness</a>" by Ed Finkler (<a href="https://twitter.com/funkatron">@funkatron</a>) where he discussed the issues people face who suffer a mental illness. It was an emotional talk where Ed described his own experiences and how his mind made him think about things differently then the rest of us. For me it was a real eye-opener and made me understand that there are people that don't really take things for granted.<br/><br/>This year's edition was filed with very good talks and it's almost impossible to give my feedback on all of them. A few talks that I attended really stood out that I would really want to promote here.<br/><br/><a href="https://twitter.com/enygma">Chris Cornut</a>, the driving force behind <a href="http://phpdeveloper.org/">phpdeveloper.org</a>, talked about "<a href="https://speakerdeck.com/ccornutt/beyond-the-basics-security-with-php-1">Beyond the Basics: Security with PHP</a>" where he did not just list the top 10 of <a href="https://www.owasp.org/index.php/Main_Page">OWASP</a>, but also gave good advices on how to protect yourself against most of the common attacks. A good closing hint: be better secured than the next guy.<br/><br/><a href="https://twitter.com/jeremykendall">Jeremy Kendall</a> was giving good advice on how to improve your code you wrote a couple of weeks or months ago in his talk "<a href="http://www.slideshare.net/jeremykendall/php-102-out-with-the-bad-in-with-the-good-21331876">PHP 102: Out with the Bad, In with the Good</a>". What I like about Jeremy is he can bring very complex subjects in an easy, understandable way that even a novice can understand complex software engineering stuff. And so he did with this talk.<br/><br/>One talk I missed which I really wanted to see was the <a href="http://www.slideshare.net/VampyreBytes/php-ooh-shiny">Distractions</a> talk of <a href="https://twitter.com/sprunka">Sean Prunka</a>, or how to deal with distractions when you're a developer. When I look at the<a href="https://joind.in/8152"> reviews on joind.in</a> I see he did an amazing good job giving this was his first conference talk ever. So hopefully he will do a webinar or an online recording of this talk *hint, hint*.<br/><br/>This year <a href="http://in2it.be/">my company</a> was sponsoring the hackathon and can be called a good success, knowing we had to compete against Lego fun party. According to <a href="https://twitter.com/lornajane">Lorna</a> a bunch of pull requests were made for joind.in (the community feedback platform for conference speakers). And we captured the first pull request on twitter.<br/><br/><blockquote class="twitter-tweet">Can I get a woot? First @<a href="https://twitter.com/joindin">joindin</a> pull request of the night has been merged at <a href="https://twitter.com/search/%23tek13">#tek13</a> hackathon!<br/>— Lorna Mitchell (@lornajane) <a href="https://twitter.com/lornajane/status/335177872660656128">May 16, 2013</a></blockquote>&lt;script async="" charset="utf-8" src="//platform.twitter.com/widgets.js"/><br/>At the introduction of the hackathon we also had a nice surprise for <a href="https://twitter.com/caseysoftware">Mr. Keith Casey</a> from his colleagues at <a href="http://twillio.com/">Twillio</a> where he worked 2 years now.<br/><br/><iframe allowfullscreen="" frameborder="0" height="315" src="https://www.&lt;/body>"/><p><i>Truncated by Planet PHP, read more at <a href="http://feedproxy.google.com/~r/dragonbe-php/~3/3oE_G4Pmuho/survived-php-tek-2013.html">the original</a> (another 2560 bytes)</i></p>]]></content></entry><entry><title type="text">5 Reasons Why the Web Platform War is Over: PHP Won with 75% says Google</title><link rel="alternate" type="text/html" href="http://www.phpclasses.org/blog/post/208-5-Reasons-Why-the-Web-Platform-War-is-Over-PHP-Won-with-75-says-Google.html" title="5 Reasons Why the Web Platform War is Over: PHP Won with 75% says Google"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~o2j" title="Shortlink to http://www.phpclasses.org/blog/post/208-5-Reasons-Why-the-Web-Platform-War-is-Over-PHP-Won-with-75-says-Google.html"/><author><name>PHP Classes</name></author><id>http://www.phpclasses.org/blog/post/208-5-Reasons-Why-the-Web-Platform-War-is-Over-PHP-Won-with-75-says-Google.html</id><updated>2013-05-20T10:43:00Z</updated><published>2013-05-20T10:43:00Z</published><content type="html"><![CDATA[<div style="clear: both">
<div style="margin-top: 1ex"><a href="http://www.phpclasses.org/blog/post/208-5-Reasons-Why-the-Web-Platform-War-is-Over-PHP-Won-with-75-says-Google.html">5 Reasons Why the Web Platform War is Over: PHP Won with 75% says Google</a></div>
<div style="margin-top: 1ex">By Manuel Lemos</a></div>
<div style="margin-top: 1ex">During Google I/O 2013 event a Google manager said PHP runs on 75% of the Web sites. So they decided to finally support PHP as in their AppEngine hosting service.<br />
<br />
Read this article to understand why this puts an end to years of false claims that PHP was losing market, as well what it means to Web developers using PHP or other languages.</a></div>
</div>
]]></content></entry><entry><title type="text">Offline Processing in PHP with Advanced Queuing </title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/feedburner/ChristopherJonesOnPHP/~3/5z0Kq_laNpI/offline_processing_in_php_with" title="Offline Processing in PHP with Advanced Queuing "/><link rel="shortlink" type="text/html" href="http://planet-php.org/~oZw" title="Shortlink to http://feedproxy.google.com/~r/feedburner/ChristopherJonesOnPHP/~3/5z0Kq_laNpI/offline_processing_in_php_with"/><author><name>Christopher Jones</name></author><id>https://blogs.oracle.com/opal/entry/offline_processing_in_php_with</id><updated>2013-05-16T20:14:00Z</updated><published>2013-05-16T20:14:00Z</published><content type="html"><![CDATA[<p>Offloading slow batch tasks to an external process is a common
method of improving website responsiveness.  One great way to initiate
such background tasks in PHP is to use Oracle Streams Advanced Queuing
in a producer-consumer message passing fashion. Oracle AQ is highly
configurable. Messages can queued by multiple producers. Different
consumers can filter messages.  From PHP, the PL/SQL interface to AQ
is used.  There are also Java, C and HTTPS interfaces, allowing wide
architectural freedom.</p>

<p>The following example simulates an application user registration
system where the PHP application queues each new user's street
address. An external system monitoring the queue can then fetch and
process that address. In real life the external system might initiate
a snail-mail welcome letter, or do further, slower automated
validation on the address.</p>

<p>The following SQL*Plus script <tt>qcreate.sql</tt> creates a new
Oracle user <tt>demoqueue</tt> with permission to create and use
queues. A payload type for the address is created and a queue is set
up for this payload.  </p>

<pre>
-- qcreate.sql

connect / as sysdba
drop user demoqueue cascade;

create user demoqueue identified by welcome;
grant connect, resource to demoqueue;
grant aq_administrator_role, aq_user_role to demoqueue;
grant execute on dbms_aq to demoqueue;
grant create type to demoqueue;

connect demoqueue/welcome@localhost/orcl

-- The data we want to queue
create or replace type user_address_type as object (
  name        varchar2(10),
  address     varchar2(50)
);
/

-- Create and start the queue
begin
 dbms_aqadm.create_queue_table(
   queue_table        =>  'demoqueue.addr_queue_tab',
   queue_payload_type =>  'demoqueue.user_address_type');
end;
/

begin
 dbms_aqadm.create_queue(
   queue_name         =>  'demoqueue.addr_queue',
   queue_table        =>  'demoqueue.addr_queue_tab');
end;
/

begin
 dbms_aqadm.start_queue(
   queue_name         => 'demoqueue.addr_queue',
   enqueue            => true);
end;
/
</pre>

<p>The script <tt>qhelper.sql</tt> creates two useful helper functions
to enqueue and dequeue messages:</p>

<pre>
-- qhelper.sql
-- Helpful address enqueue/dequeue procedures

connect demoqueue/welcome@localhost/orcl

-- Put an address in the queue
create or replace procedure my_enq(name_p in varchar2, address_p in varchar2) as
  user_address       user_address_type;
  enqueue_options    dbms_aq.enqueue_options_t;
  message_properties dbms_aq.message_properties_t;
  enq_id             raw(16);
begin
  user_address := user_address_type(name_p, address_p);
  dbms_aq.enqueue(queue_name         => 'demoqueue.addr_queue',
                  enqueue_options    => enqueue_options,
                  message_properties => message_properties,
                  payload            => user_address,
                  msgid              => enq_id);
  commit;
end;
/
show errors

-- Get an address from the queue
create or replace procedure my_deq(name_p out varchar2, address_p out varchar2) as
  dequeue_options    dbms_aq.dequeue_options_t;
  message_properties dbms_aq.message_properties_t;
  user_address       user_address_type;
  enq_id             raw(16);
begin
  dbms_aq.dequeue(queue_name         => 'demoqueue.addr_queue',
                  dequeue_options    => dequeue_options,
                  message_properties => message_properties,
                  payload            => user_address,
                  msgid              => enq_id);
  name_p    := user_address.name;
  address_p := user_address.address;
  commit;
end;
/
show errors
</pre>

<p>The script <tt>newuser.php</tt> is the part of the PHP application
that handles site registration for a new user. It queues a message
containing their address and continues executing:</p>

<pre>
&lt;?php
// newuser.php

$c = oci_connect("demoqueue", "welcome", "localhost/orcl");

// The new user details
$username = 'Fred';
$address  = '500 Oracle Parkway';

// Enqueue the address for later offline handling
$s = oci_parse($c, "begin my_enq(:username, :address); end;");
oci_bind_by_name($s, ":username", $username, 10);
oci_bind_by_name($s, ":address",  $address,  50);
$r = oci_execute($s);

// Continue executing
echo "Welcome $username\n";

?>
</pre>

<p>It executes an anonymous PL/SQL block to create and enqueue the
address message. The immediate script output is simply the echoed
welcome message: </p>

<pre>
Welcome Fred
</pre>

<p>Once this PHP script is executed, any application can dequeue the
new message at its leisure.  For example, the following SQL*Plus
commands call the helper <tt>my_deq()</tt> dequeue function and
displays the user details: </p>

<pre>
-- getuser.sql

connect demoqueue/welcome@localhost/orcl

set serveroutput on
declare
  name varchar2(10);
  address varchar2(50);
begin
  my_deq(name, address);
  dbms_output.put_line('Name     : ' || name);
  dbms_output.put_line('Address  : ' || address);
end;
/
</pre>

<p>The</p><p><i>Truncated by Planet PHP, read more at <a href="http://feedproxy.google.com/~r/feedburner/ChristopherJonesOnPHP/~3/5z0Kq_laNpI/offline_processing_in_php_with">the original</a> (another 1511 bytes)</i></p>]]></content></entry><entry><title type="text">Slides: Behat &amp; Beautiful APIs</title><link rel="alternate" type="text/html" href="http://qafoo.com/blog/044_slides_bdd_behat_beautiful_apis.html" title="Slides: Behat &amp; Beautiful APIs"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~oY3" title="Shortlink to http://qafoo.com/blog/044_slides_bdd_behat_beautiful_apis.html"/><author><name>Qafoo - PHP</name></author><id>http://qafoo.com/blog/044_slides_bdd_behat_beautiful_apis.html</id><updated>2013-05-16T06:14:00Z</updated><published>2013-05-16T06:14:00Z</published><content type="html"><![CDATA[Last Wednesday I did a little talk marathon by first presenting a Webinar on Behavior Driven Development with Behat and afterwards going straight to Cologne for the Symfony Usergroup, where I spoke about Designing Beautiful APIs. Find the slides of my talks here.
]]></content></entry><entry><title type="text">Publishing Security Disclosures In Consumable Formats For Simpler Aggregation and Security Checking</title><link rel="alternate" type="text/html" href="http://blog.astrumfutura.com/2013/05/publishing-security-disclosures-in-consumable-formats-for-simpler-aggregation-and-security-checking/" title="Publishing Security Disclosures In Consumable Formats For Simpler Aggregation and Security Checking"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~oYx" title="Shortlink to http://blog.astrumfutura.com/2013/05/publishing-security-disclosures-in-consumable-formats-for-simpler-aggregation-and-security-checking/"/><author><name>P&#xE1;draic Brady</name></author><id>http://blog.astrumfutura.com/?p=998</id><updated>2013-05-15T14:43:00Z</updated><published>2013-05-15T14:43:00Z</published><content type="html"><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.astrumfutura.com%2F2013%2F05%2Fpublishing-security-disclosures-in-consumable-formats-for-simpler-aggregation-and-security-checking%2F"><br/><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.astrumfutura.com%2F2013%2F05%2Fpublishing-security-disclosures-in-consumable-formats-for-simpler-aggregation-and-security-checking%2F&source=padraicb&style=normal&service=bit.ly&service_api=padraic%3AR_94101570b7e190f3de921bc15bb9438d&hashtags=php&b=2" height="61" width="50"/><br/></a>
		</div>
<div class="mceTemp">
<dl class="wp-caption alignright zemanta-img" style="width: 210px;"><dt class="wp-caption-dt"><a href="http://commons.wikipedia.org/wiki/File:Cooperation.svg" target="_blank"><img class="zemanta-img-inserted zemanta-img-configured" title="English: Decentralised cooperation, many-to-ma..." src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b8/Cooperation.svg/300px-Cooperation.svg.png" alt="English: Decentralised cooperation, many-to-ma..." width="200"/></a></dt>
</dl></div>
<p>This is a branch off from a separate discussion on the PHP-FIG <a href="https://groups.google.com/forum/?fromgroups=#!forum/php-fig" target="_blank">mailing list</a> about other ways the Framework Interoperability Group can encourage and foster wider interoperability among its member projects (and by extension, the whole PHP community). I’ll start by noting two interesting developments in recent months and one long standing best practice.</p>
<h2>1. Launch of the SensioLabs Security Advisory Checker</h2>
<p>The <a href="https://security.sensiolabs.org/" target="_blank">SensioLabs Security Advisor Checker</a> is described on its website as follows.</p>
<blockquote><p>You manage your PHP project dependencies with Composer, right? But are  you sure that your project does not depend on a package with known  security issues? The SensioLabs security advisories checker is a simple  tool, available as a web service or as an online application, that uses  the information from your composer.lock file to check for known security  vulnerabilities. This checker is a frontend for the security advisories  database.</p></blockquote>
<p>The service operates by having people submit vulnerability data, as YAML files, to a centralised Github repository through pull requests. The upside is that the vulnerability data can be peer reviewed and centrally dispersed either online or via a service API. The downside is that you need to find vulnerability disclosures and people to submit them. The service currently covers Symfony, Zend Framework, Doctrine, Twig and FriendsOfSymfony bundles. It’s a tiny sample of packages available through Composer. I’m also not entirely sure if it’s sufficiently fine grained to report vulnerabilities on a project’s sub-packages where you have no direct dependency on the aggregate package (e.g. using zendframework/zend-db instead of zendframework/zendframework). That said, this is a working model of a service for checking your dependencies.</p>
<p>That said, the service exhibits an ambitious idea – projects sharing their vulnerability disclosures or advisories in a way that allows for automatically checking if any of your projects need to have their dependencies updated for security reasons.</p>
<h2>2. <a class="zem_slink" title="OWASP" rel="wikipedia" href="http://en.wikipedia.org/wiki/OWASP" target="_blank">OWASP</a>‘s Top 10 security risks for 2013 includes “A9 – Using Components with Known Vulnerabilities”</h2>
<p><a href="https://www.owasp.org/index.php/Top_10_2013-A9" target="_blank">This is a new entry</a> onto OWASP’s Top 10 (which is currently at release candidate status for 2013). In summary, it recognises that applications are becoming ever more dependent on code not developed internally. We’ve had web application frameworks for years. Composer and Github have unleashed a storm of accessible libraries, bundles, modules, and other units of reuse that have revealed Not Invented Here (<a class="zem_slink" title="Not invented here" rel="wikipedia" href="http://en.wikipedia.org/wiki/Not_invented_here" target="_blank">NIH Syndrome</a>) as a psychological problem in ways not previously possible.</p>
<p>As reliance on externally controlled dependencies increases, so too does the risk of your applications using insecure dependencies. This is a risk that requires a lot of work to mitigate. For each dependency, you need to do a security review (no, I’m not kidding), check for security disclosures (whether voluntary or involuntary) and ensure that you end up rolling out to production with safe versions.</p>
<p>Quoting from the OWASP advice on preventing the use of components with known vulnerabilities…</p>
<blockquote><p>One option is not to use compone</p></blockquote><p><i>Truncated by Planet PHP, read more at <a href="http://blog.astrumfutura.com/2013/05/publishing-security-disclosures-in-consumable-formats-for-simpler-aggregation-and-security-checking/">the original</a> (another 4681 bytes)</i></p>]]></content></entry><entry><title type="text">How we organize our websites</title><link rel="alternate" type="text/html" href="http://blog.preinheimer.com/index.php?/archives/414-How-we-organize-our-websites.html" title="How we organize our websites"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~oYu" title="Shortlink to http://blog.preinheimer.com/index.php?/archives/414-How-we-organize-our-websites.html"/><author><name>Paul Reinheimer</name></author><id>http://blog.preinheimer.com/index.php?/archives/414-guid.html</id><updated>2013-05-15T13:19:00Z</updated><published>2013-05-15T13:19:00Z</published><content type="html"><![CDATA[
    <p>We recently migrated <a href="http://wheresitup.com/">Where’s it Up</a> to our fancy <a href="http://blog.preinheimer.com/index.php?/archives/413-Buying-a-Zoo-server.html">new hardware</a>, it took a bit more effort than planned (some pains surrounding our use of MongoDB) but I’m incredibly happy with how things have ended up. As mentioned earlier we’ve purchased our own hardware, and have racked it with <a href="http://www.peer1.com/">Peer 1</a> here in Toronto. We’ve installed a hypervisor, and are running different VMs for critical services: MySQL, Mongo, Web Production, Web Development, etc. </p>

<p>Our websites sit under <span class="code-inline">/var/www</span>, so Where’s it Up resides at <span class="code-inline">/var/www/wheresitup.com/</span>. Under that directory we have <span class="code-inline">/noweb/apache/</span> which contains both <span class="code-inline">wheresitup.com</span> and <span class="code-inline">dev.wheresitup.com</span>, configuration files for apache. The entire <span class="code-inline">/var/www/wheresitup.com</span> directory tree resides nicely in our version control system. We hand off key configuration options to our websites through the use of Apache’s SetEnv, things like <span class="code-inline">SetEnv mysql_host dev.mysql</span>, these apache configuration options represent the only difference between the two code bases. </p>
     
<p style="margin-left: 10px; color: #7C8699;">I’ve written or maintained code that implied the state (Dev/Production/Stage) based on the Host, directory, or other factors in the past. I much prefer grabbing an explicit constant. It feels cleaner, I don’t have to read up on which variables could have been manipulated by an attacker, and I can ask the exact question I want answered: Is this dev, rather than “is the url the one that means this is dev”. </p>

<p>This allows us to match our Development and Production virtual machines very closely, the only difference between the two is which apache configuration file is sym-linked under <span class="code-inline">/etc/apache2/conf/sites-enabled</span>. Clearly WebDev links to the <span class="code-inline">dev.wheresitup.com</span> file, and WebProd links to <span class="code-inline">wheresitup.com</span>. We actually cloned one machine to produce the other. </p>

<p>Keeping the configuration files so close also makes a lot of sense to me. If I’m adding a new constant on Dev, the immediate presence of Prod reminds me that I’ll need to add it there as well. Storing the entire site: PHP code, supporting apache configuration, etc, all in once place makes it easy to avoid forgetting anything (which is easy when it's a different file on a different server). The only exception is SSL certificates. We currently host a number of our projects with GitHub, and trust them as we might, we’re not willing to hand those to anyone else. </p>
  
    ]]></content></entry><entry><title type="text">Dealing with duplicated code</title><link rel="alternate" type="text/html" href="http://www.brandonsavage.net/dealing-with-duplicated-code/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=dealing-with-duplicated-code" title="Dealing with duplicated code"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~oYp" title="Shortlink to http://www.brandonsavage.net/dealing-with-duplicated-code/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=dealing-with-duplicated-code"/><author><name>Brandon Savage</name></author><id>http://www.brandonsavage.net/?p=2460</id><updated>2013-05-15T11:00:00Z</updated><published>2013-05-15T11:00:00Z</published><content type="html"><![CDATA[We’ve all seen it: we’re working along, and we come across code that just has a feel to it. It’s like déjà vu. You’ve seen this code before. You open another file – sure enough, there it is. The same code. Almost line for line. In large code bases, it’s likely that there are dozens [...]]]></content></entry><entry><title type="text">Getting Started with PHP Zend Framework 2 for Oracle DB</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/feedburner/ChristopherJonesOnPHP/~3/VICQhBJOllM/getting_started_with_php_zend" title="Getting Started with PHP Zend Framework 2 for Oracle DB"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~oXO" title="Shortlink to http://feedproxy.google.com/~r/feedburner/ChristopherJonesOnPHP/~3/VICQhBJOllM/getting_started_with_php_zend"/><author><name>Christopher Jones</name></author><id>https://blogs.oracle.com/opal/entry/getting_started_with_php_zend</id><updated>2013-05-14T18:56:00Z</updated><published>2013-05-14T18:56:00Z</published><content type="html"><![CDATA[<p>This post shows the changes to the <a href="http://zf2.readthedocs.org/en/latest/user-guide/overview.html">ZF2 tutorial application</a> to allow it to run with Oracle
Database 11<i>g</i>R2.</p>

<p>Oracle Database SQL identifiers are case insensitive by default so
"select Abc from Xyz" is the same as "select abc from xyz".  However
the identifier metadata returned to programs like PHP is standardized
to uppercase by default.  After executing either query PHP knows that
column "ABC" was selected from table "XYZ". </p>

<p>In PHP code, array indices and object attributes need to match the
schema identifier case that is returned by the database. This is
either done by using uppercase indices and attributes in the PHP code,
or by forcing the SQL schema to case-sensitively use lower-case
names.</p>

<p>The former approach is more common, and is shown here.</p>

<p>The instructions for creating the sample ZF2 application are <a href="http://zf2.readthedocs.org/en/latest/user-guide/overview.html">here</a>.  Follow those steps as written, making the substitutions
shown below.</p>

<h2>Schema</h2>

<p>In Oracle 11<i>g</i>R2, the schema can be created like:</p>

<pre>
DROP USER ZF2 CASCADE;

CREATE USER ZF2 IDENTIFIED BY WELCOME
    DEFAULT TABLESPACE USERS QUOTA UNLIMITED ON USERS
    TEMPORARY TABLESPACE TEMP;

GRANT CREATE SESSION
    , CREATE TABLE
    , CREATE PROCEDURE
    , CREATE SEQUENCE
    , CREATE TRIGGER
    , CREATE VIEW
    , CREATE SYNONYM
    , ALTER SESSION
TO ZF2;

CONNECT ZF2/WELCOME

CREATE TABLE ALBUM (
  ID NUMBER NOT NULL,
  ARTIST VARCHAR2(100) NOT NULL,
  TITLE VARCHAR2(100) NOT NULL,
  PRIMARY KEY (ID)
);

CREATE SEQUENCE ALBUMSEQ;

CREATE TRIGGER ALBUMTRIGGER BEFORE INSERT ON ALBUM FOR EACH ROW
BEGIN
  :NEW.ID := ALBUMSEQ.NEXTVAL;
END;
/

INSERT INTO ALBUM (ARTIST, TITLE)
    VALUES ('The  Military  Wives', 'In  My  Dreams');
INSERT INTO ALBUM (ARTIST, TITLE)
    VALUES ('Adele', '21');
INSERT INTO ALBUM (ARTIST, TITLE)
    VALUES ('Bruce  Springsteen', 'Wrecking Ball (Deluxe)');
INSERT INTO ALBUM (ARTIST, TITLE)
    VALUES ('Lana  Del  Rey', 'Born  To  Die');
INSERT INTO ALBUM (ARTIST, TITLE)
    VALUES ('Gotye', 'Making  Mirrors');

COMMIT;
</pre>

<h2>Driver and Credentials</h2>

<p>The driver and credentials are Oracle-specific. Always use the OCI8
adapter in ZF, since it is more stable and has better scalability.
Specifying a character set will make connection faster.</p>

<b>zf2-tutorial/config/autoload/global.php:</b>

<pre> return array(
     'db' => array(
-        'driver'         => 'Pdo',
-        'dsn'            => 'mysql:dbname=zf2tutorial;host=localhost',
-        'driver_options' => array(
-            PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
-        ),
+        'driver'         => 'OCI8',
+        'connection_string' => 'localhost/orcl',
+        'character_set' => 'AL32UTF8',
     ),
     'service_manager' => array(
         'factories' => array(
</pre>

<b>zf2-tutorial/config/autoload/local.php:</b>
 
<pre> return array(
     'db' => array(
-        'username' => 'YOUR USERNAME HERE',
-        'password' => 'YOUR USERNAME HERE',
+        'username' => 'ZF2',
+        'password' => 'WELCOME',
     ),
     // Whether or not to enable a configuration cache.
     // If enabled, the merged configuration will be cached and used in
</pre>

<h2>Attribute & Index Changes</h2>

<p>The rest of the application changes are just to handle the case of
the Oracle identifiers correctly.</p>

<b>zf2-tutorial/module/Album/Module.php</b>

<pre>
                     $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                     $resultSetPrototype = new ResultSet();
                     $resultSetPrototype->setArrayObjectPrototype(new Album());
-                    return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
+                    return new TableGateway('ALBUM', $dbAdapter, null, $resultSetPrototype);
                 },
             ),
         );
</pre>

<b>zf2-tutorial/module/Album/view/album/album/add.phtml</b>
<pre>
 $form->prepare();
 
 echo $this->form()->openTag($form);
-echo $this->formHidden($form->get('id'));
-echo $this->formRow($form->get('title'));
-echo $this->formRow($form->get('artist'));
+echo $this->formHidden($form->get('ID'));
+echo $this->formRow($form->get('TITLE'));
+echo $this->formRow($form->get('ARTIST'));
 echo $this->formSubmit($form->get('submit'));
 echo $this->form()->closeTag();
</pre>

<b>zf2-tutorial/module/Album/view/album/album/delete.phtml</b>

<pre> &lt;h1>&lt;?php echo $this->escapeHtml($title); ?>&lt;/h1>
 
 &lt;p>Are you sure that you want to delete
-'&lt;?php echo $this->escapeHtml($album->title); ?>' by
-'&lt;?php echo $this->escapeHtml($album->artist); ?>'?
+'&lt;?php echo $this->escapeHtml($album->TITLE); ?>' by
+'&lt;?php echo $this->esc</pre><p><i>Truncated by Planet PHP, read more at <a href="http://feedproxy.google.com/~r/feedburner/ChristopherJonesOnPHP/~3/VICQhBJOllM/getting_started_with_php_zend">the original</a> (another 7231 bytes)</i></p>]]></content></entry><entry><title type="text">Improve PHP session cookie security</title><link rel="alternate" type="text/html" href="http://simonholywell.com/post/2013/05/improve-php-session-cookie-security.html" title="Improve PHP session cookie security"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~oXv" title="Shortlink to http://simonholywell.com/post/2013/05/improve-php-session-cookie-security.html"/><author><name>Simon Holywell</name></author><id>http://simonholywell.com/post/2013/05/improve-php-session-cookie-security.html</id><updated>2013-05-14T10:42:00Z</updated><published>2013-05-14T10:42:00Z</published><content type="html"><![CDATA[]]></content></entry></feed>
