<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Calvin Freitas &#187; PHP</title>
	<atom:link href="http://calvinf.com/blog/category/code/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://calvinf.com</link>
	<description>Web Consulting, Development, and Marketing Services for Your Small Business</description>
	<lastBuildDate>Sat, 07 Apr 2012 19:31:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Installing, Configuring, and Using the XHP PHP Extension by Facebook</title>
		<link>http://calvinf.com/blog/2010/02/10/installing-configuring-and-using-the-xhp-php-extension-by-facebook/</link>
		<comments>http://calvinf.com/blog/2010/02/10/installing-configuring-and-using-the-xhp-php-extension-by-facebook/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 00:07:08 +0000</pubDate>
		<dc:creator>Calvin Freitas</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[XHP]]></category>

		<guid isPermaLink="false">http://calvinf.com/?p=262</guid>
		<description><![CDATA[Facebook announced the release of XHP yesterday. It is an extension for PHP which provides enhancements to the PHP language syntax and gives the language some convenient capabilities. In this post I will provide you links to the essential sources of information about XHP, show some XHP sample code, and discuss the installation process for [...]]]></description>
			<content:encoded><![CDATA[<p>Facebook <a href="http://www.facebook.com/notes/facebook-engineering/xhp-a-new-way-to-write-php/294003943919">announced the release of XHP</a> yesterday.  It is an extension for PHP which provides enhancements to the PHP language syntax and gives the language some convenient capabilities.</p>
<p>In this post I will provide you links to the essential sources of information about XHP, show some XHP sample code, and discuss the installation process for XHP on Ubuntu with Apache and PHP5.</p>
<p><strong>The Essential Information</strong><br />
<a href="http://github.com/facebook/xhp">Download XHP at GitHub</a><br />
<a href="http://wiki.github.com/facebook/xhp/">How XHP Works</a><br />
<a href="http://wiki.github.com/facebook/xhp/building-xhp">Building XHP</a><br />
<a href="http://wiki.github.com/facebook/xhp/configuration">Configuring XHP</a><br />
<span id="more-262"></span><br />
<b>Example XHP Sample Code (<a href="http://xhp.calvinf.com/" target="_blank">View Code in Action</a>):</b></p>
<pre class="brush: php; title: ; notranslate">&lt;?php
require_once('/home/cal/facebook-xhp-290b185/php-lib/init.php');
$name  = 'Calvin Freitas';
$title = &quot;{$name} loves XHP!&quot;;
$url   = 'http://calvinf.com/';

$permalink = 'http://wp.me/pcoLC-4e';

#create a &lt;head&gt; element
$head =
  &lt;head&gt;
   &lt;title&gt;{$title}&lt;/title&gt;
  &lt;/head&gt;;

#create a div
$div =
  &lt;div id=&quot;header&quot;&gt;
    &lt;h1&gt;{$title}&lt;/h1&gt;
  &lt;/div&gt;;

$body =
  &lt;body&gt;
    {$div}
    &lt;div&gt;
      &lt;p&gt;My name is {$name} and you should go visit &lt;a href={$url}&gt;my website&lt;/a&gt; now.&lt;/p&gt;
      &lt;p&gt;Read my &lt;a href={$permalink}&gt;guide to installing XHP on Ubuntu&lt;/a&gt;. It includes the source code for this page. Comments and corrections are welcome.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/body&gt;;

echo
&lt;html&gt;
  {$head}
  {$body}
&lt;/html&gt;;
?&gt;</pre>
<p><b>A few syntax notes</b><br />
XHP forces you to properly nest tags &#8212; make sure you close them properly or it won&#8217;t compile and it will throw errors.  Because XHP auto-escapes, when you&#8217;re creating a link (such as in an <em>a</em> element), you don&#8217;t need to put quotes around it.</p>
<pre class="brush: php; title: ; notranslate">&lt;a href={$permalink}&gt;guide to installing XHP on Ubuntu&lt;/a&gt;</pre>
<p><strong>Installing XHP on Ubuntu</strong><br />
Server: Ubuntu 9.10 running on a slice at the Rackspace Cloud.<br />
Web server: Apache 2<br />
<a href="http://articles.slicehost.com/2008/4/25/ubuntu-hardy-installing-apache-and-php5">Apache installation guide</a> (Slicehost article, but generally applicable)</p>
<p>Below I will go into more detail about the installation process.<br />
<!--more--><br />
There are packages for all the prerequisites in Ubuntu (installation will be similar on Debian, though package names my vary).</p>
<p><code>sudo apt-get install php5 php5-common php5-cli php5-dev libapache2-mod-php5</code><br />
<code>sudo apt-get install build-essential gcc flex bison re2c</code></p>
<p>The package manager will include other prerequisite packages.</p>
<p>After you&#8217;ve installed these packages, download the <a href="http://github.com/facebook/xhp/downloads">latest tagged release of XHP</a> from GitHub to your server.</p>
<p>Then, you&#8217;ll need to make it.  Unzip/untar the file, go to that directory, and run the following commands. (Use <em>sudo</em> as necessary.)<br />
<code>phpize<br />
./configure<br />
make<br />
make install<br />
</code></p>
<p>Note regarding <span class="code">make test</span>: the tests failed for me because it wasn&#8217;t finding my currently installed PHP5 modules. I ran <span class="code">make install</span> and it worked anyway.  There should be a way to include the modules path in the compilation, but at this time I have not found it.</p>
<p>After installing the module, you must configure Apache to include the XHP module in the php.ini file.  On my system, the file is located in <span class="code">/etc/php5/apache2</span>. Find the line with <span class="code">extension_dir</span> &#8212; mine is the following:<br />
<code>extension_dir = "/usr/lib/php5/20060613/"</code></p>
<p>In /etc/php5/apache2/conf.d, create a file called xhp.ini.<br />
<b>xhp.ini</b><br />
<code>#load xhp<br />
extension=xhp.so</code></p>
<p>Now, at this point everything should work, but some users are reporting <a href="http://github.com/facebook/xhp/issues#issue/2">issues with XHP on Ubuntu</a> systems, but there is a solution &#8211; you may need to include files from the php-lib folder (in the source code folder where you ran make).  See the &#8220;require_once&#8221; function used in the sample code above.</p>
]]></content:encoded>
			<wfw:commentRss>http://calvinf.com/blog/2010/02/10/installing-configuring-and-using-the-xhp-php-extension-by-facebook/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using apc
Database Caching 4/6 queries in 0.002 seconds using apc
Object Caching 324/325 objects using apc
Content Delivery Network via Amazon Web Services: CloudFront: static.calvinf.com

Served from: calvinf.com @ 2012-05-19 09:07:07 -->
