<?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>Web:Extend &#187; PHP5</title>
	<atom:link href="http://blog.extend.ws/category/php5/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.extend.ws</link>
	<description>Web:Extend's Development Blog</description>
	<lastBuildDate>Thu, 16 Sep 2010 20:38:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Web:Extend 0.5 Beta</title>
		<link>http://blog.extend.ws/2009/03/24/webextend-05-beta/</link>
		<comments>http://blog.extend.ws/2009/03/24/webextend-05-beta/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 23:37:41 +0000</pubDate>
		<dc:creator>Loïc Hoguin</dc:creator>
				<category><![CDATA[PHP5]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[Web:Extend]]></category>

		<guid isPermaLink="false">http://blog.extend.ws/?p=64</guid>
		<description><![CDATA[We released a new version of the Web:Extend framework today. The work continue towards the 1.0 release.
The current version fixes a number of issues and makes various improvements. The API didn&#8217;t change much, although we did a few additions:

Caching module, with an APC driver (memcached planned at a later time)
Improved encoding support, adding encoding settings [...]]]></description>
			<content:encoded><![CDATA[<p>We released a new version of the Web:Extend framework today. The work continue towards the 1.0 release.</p>
<p>The current version fixes a number of issues and makes various improvements. The API didn&#8217;t change much, although we did a few additions:</p>
<ul>
<li>Caching module, with an APC driver (memcached planned at a later time)</li>
<li>Improved encoding support, adding encoding settings in database and output drivers</li>
<li>CGI support</li>
<li>Full SQL Server and Oracle support, including DBMeta drivers</li>
<li>Forms externals (see below)</li>
<li>Full LDAP support, including an LDAP authentication driver</li>
<li>Much improved API browser (see below)</li>
</ul>
<p><strong>Forms externals:</strong></p>
<p>Forms externals are a mechanism allowing a developer to build part of a form dynamically. Currently it allows a developer to retrieve options for selectable widgets directly from the model domain just by specifying a function or method to call. For example you could retrieve a list of users from a users set using <code>&lt;external type="set" source="myUsersSet::fetchFormOptions"/&gt;</code>. This method would return value/label pairs to be used as option items. It can also be used for hierarchical data types, where the hierarchy is represented by a multi-level array.</p>
<p><strong>API browser:</strong></p>
<p>The <a href="http://api.extend.ws">new API browser</a> is based on the <a href="http://www.nicolas.rudas.info/jquery/finder/">jQuery Finder plugin</a>. There is still some quirks here and there, and we also intend to add additional functionality with subsequent releases (like a search function, allowing you to find the deprecated API, or all the interfaces, for example), but the main functionality is there and the result is already better than the original. Feel free to comment on it and suggest how we could improve it.</p>
<p><strong>New server:</strong></p>
<p>Two weeks ago we moved to a new and much bigger server. Now that we have enough flexibility we intend to put various services, including daily test reports from various sources (anyone will be able to setup a daily test that will be aggregated and displayed on our server). We&#8217;ll also start a few projects that will demonstrate how to use the framework. More information on that later.</p>
<p><strong>Next release:</strong></p>
<p>Our work will continue in the next release. It will include plugins, since after some discussion we now have a better idea of how we want to implement that. It will also include various improvements, most of them detailed <a href="http://wee.extend.ws/milestone/0.6">in the roadmap</a>.</p>
<p>Thanks for your interest and see you soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.extend.ws/2009/03/24/webextend-05-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web:Extend 0.4 Beta</title>
		<link>http://blog.extend.ws/2009/02/14/webextend-04-beta/</link>
		<comments>http://blog.extend.ws/2009/02/14/webextend-04-beta/#comments</comments>
		<pubDate>Sat, 14 Feb 2009 19:44:08 +0000</pubDate>
		<dc:creator>Loïc Hoguin</dc:creator>
				<category><![CDATA[PHP5]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[Web:Extend]]></category>

		<guid isPermaLink="false">http://blog.extend.ws/?p=57</guid>
		<description><![CDATA[Hello folks,
Today we released the next version of the Web:Extend framework, 0.4 beta.
This release introduces many many things. We improved the rendering pipeline; added an LDAP module (this is still a work in progress); improved the HTTP classes (cookies, sessions, file uploads); added QUnit, jQuery&#8217;s unit testing framework, to test these HTTP classes; and last [...]]]></description>
			<content:encoded><![CDATA[<p>Hello folks,</p>
<p>Today we released the next version of the Web:Extend framework, 0.4 beta.</p>
<p>This release introduces many many things. We improved the rendering pipeline; added an <a href="http://wee.extend.ws/wiki/Documentation/Modules/LDAP">LDAP module</a> (this is still a work in progress); improved the <a href="http://wee.extend.ws/wiki/Documentation/Modules/HTTP">HTTP classes</a> (cookies, sessions, file uploads); added <a href="http://wee.extend.ws/wiki/Documentation/Tools/QUnit">QUnit</a>, jQuery&#8217;s unit testing framework, to test these HTTP classes; and last but not least, added the <a href="http://wee.extend.ws/wiki/Documentation/Modules/UI">UI module</a>.</p>
<p>The UI module is our answer to RAD development. It works side by side with the <a href="http://wee.extend.ws/wiki/Documentation/Modules/Model/Database/Scaffold">model scaffolding classes</a> to allow you to quickly design an application. It contains useful components like CRUD and pagination, that you only have to configure and render in your templates.</p>
<p>You can <a href="https://sourceforge.net/project/showfiles.php?group_id=212065&#038;package_id=255018&#038;release_id=661075">download the source code at sourceforge</a>. It is licensed under the <code>LGPL</code>.</p>
<p>If you have some time to spend, head over to the <a href="http://wee.extend.ws/wiki/Documentation">documentation</a> and leave us a comment, as we will use <em>your</em> input to improve the framework.</p>
<p>Next month we will release the Cache module along with a Plugins system, among other things. You might want to come back here in a week to <a href="http://wee.extend.ws/wiki/Contribute">discuss the RFC</a> about these two additions.</p>
<p>Thanks for your interest.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.extend.ws/2009/02/14/webextend-04-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web:Extend 0.3 Beta</title>
		<link>http://blog.extend.ws/2009/01/15/webextend-03-beta/</link>
		<comments>http://blog.extend.ws/2009/01/15/webextend-03-beta/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 01:48:06 +0000</pubDate>
		<dc:creator>Loïc Hoguin</dc:creator>
				<category><![CDATA[PHP5]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[Web:Extend]]></category>

		<guid isPermaLink="false">http://blog.extend.ws/?p=47</guid>
		<description><![CDATA[We&#8217;re proud to announce today the first beta release of the Web:Extend framework. This release is an important milestone because it marks significant progress since the project was started about three years ago. It&#8217;s also been almost a year since the last alpha release and a lot has changed.
The project is expected to stay in [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re proud to announce today the first beta release of <a href="http://wee.extend.ws">the Web:Extend framework</a>. This release is an important milestone because it marks significant progress since the project was started about three years ago. It&#8217;s also been almost a year since the last alpha release and a lot has changed.</p>
<p>The project is expected to stay in beta stage for at least a few months. At this time it is not stable enough for production, but it is stable enough to begin to learn about it and even to use it in small personal projects you might have. Most of the changes planned for the next releases do not change the API, with the exception of one or two function name changes. And although it&#8217;s a beta release, about 75% of the code is estimated to be <a href="http://wee.extend.ws/wiki/Contribute/CodeCoverage">covered by unit tests</a> &#8211; and this will only improve with each new beta releases.</p>
<p>The <a href="http://wee.extend.ws/wiki/Documentation">documentation</a> is becoming pretty good. A few chapters are still missing but they will be written shortly. All the essential chapters are available so learning the basics shouldn&#8217;t be a problem. A <a href="http://wee.extend.ws/wiki/Documentation/Tutorials/Pastebin">tutorial</a> is even available (more will follow). You can also use the <a href="http://api.extend.ws">API viewer</a> for fast lookup of classes or functions; once it&#8217;s loaded it runs locally.</p>
<p>This release introduces a few important features.</p>
<ul>
<li>the <a href="http://wee.extend.ws/wiki/Documentation/Modules/Forms">Forms Module</a> now uses <a href="http://en.wikipedia.org/wiki/XSLT">XSLT</a> to efficiently transform XML-based form files into (X)HTML</li>
<li><a href="http://wee.extend.ws/wiki/Documentation/Modules/Database/Meta">DbMeta</a> allows you to query a database about its structure (get table list, columns, keys&#8230;)</li>
<li>the <a href="http://wee.extend.ws/wiki/Documentation/Modules/Application">Application Module</a> implements the <a href="http://wee.extend.ws/wiki/Documentation/MVCArchitecture">MVC pattern with a passive view</a></li>
<li>the <a href="http://wee.extend.ws/wiki/Documentation/Modules/Model">Model Module</a> supports <a href="http://wee.extend.ws/wiki/Documentation/Modules/Model/Database/Scaffold">database scaffolding</a></li>
</ul>
<p>This last item is pretty exciting, especially if you pair it with the <a href="http://wee.extend.ws/wiki/Contribute/RFC/3-UI">upcoming UI Module</a>, planned for the next release, <a href="http://wee.extend.ws/milestone/0.4">0.4 beta</a>. It is scheduled to be released in about a month. We follow a <a href="http://wee.extend.ws/wiki/Contribute/LifeCycle">5-weeks per release cycle</a>.</p>
<p>You can <a href="https://sourceforge.net/project/showfiles.php?group_id=212065&#038;package_id=255018&#038;release_id=652403">download the source code at sourceforge</a>. It is licensed under the <code>LGPL</code>.</p>
<p>If you wish to help us, there is a lot you can do. The most important thing is to proof-read the <a href="http://wee.extend.ws/wiki/Documentation">documentation</a> or the <a href="http://api.extend.ws/">API</a> and to <a href="http://groups.google.com/group/wee-users">forward us</a> <em>any</em> problem you might have with it. Typos, invalid code, comprehension problems or anything else. You can also <a href="http://wee.extend.ws/wiki/Contribute#RFCIndex">discuss the various RFC</a> or try to learn how to use the framework and <a href="http://wee.extend.ws/newticket">report bugs you may find</a>. At a later time you will also be able to translate it in your language.</p>
<p>Please leave us any comment you might find relevant, as we will use <em>your</em> input to improve the framework.</p>
<p>Thanks for your interest.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.extend.ws/2009/01/15/webextend-03-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ArrayAccess Quirks</title>
		<link>http://blog.extend.ws/2008/03/01/arrayaccess-quirks/</link>
		<comments>http://blog.extend.ws/2008/03/01/arrayaccess-quirks/#comments</comments>
		<pubDate>Sat, 01 Mar 2008 15:06:25 +0000</pubDate>
		<dc:creator>Loïc Hoguin</dc:creator>
				<category><![CDATA[PHP5]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web:Extend]]></category>

		<guid isPermaLink="false">http://blog.extend.ws/2008/03/01/arrayaccess-quirks/</guid>
		<description><![CDATA[Recently we stumbled upon a bug in our framework. The problem was tricky. We were submitting values to be inserted in an SQL query and some of them weren&#8217;t found by the code that actually build the query with all the escaping needed automatically. Why&#8217;s that? Because we were passing an ArrayAccess object containing the [...]]]></description>
			<content:encoded><![CDATA[<p>Recently we stumbled upon a bug in <a href="http://wee.extend.ws">our framework</a>. The problem was tricky. We were submitting values to be inserted in an SQL query and some of them weren&#8217;t found by the code that actually build the query with all the escaping needed automatically. Why&#8217;s that? Because we were passing an <a href="http://www.php.net/~helly/php/ext/spl/interfaceArrayAccess.html">ArrayAccess</a> object containing the values instead of a normal array.</p>
<h2>The Problem</h2>
<p>It is written deep in the PHP documentation that objects that implement the interface <code>ArrayAccess</code> do not work with the array_* functions. None of them. Not even <a href="http://php.net/array_key_exists">array_key_exists</a>. You would usually use this function to check if a key exists in the array, even if the associated value is <a href="http://php.net/null">null</a>. But you can&#8217;t. Some people wrote <a href="http://bugs.php.net/bug.php?id=34934">bug</a> <a href="http://bugs.php.net/bug.php?id=34849">reports</a> to the PHP team about it. They were marked as bogus.</p>
<p>Of course, no error or warning is triggered when you use it with this function. It would be too easy. And this can leads to mistake, like the bug we found in our code.</p>
<p>So what can we use if <code>array_key_exists</code> doesn&#8217;t work?</p>
<h2>The Solution</h2>
<p>Instead of <code>array_key_exists</code> we can use the <a href="http://php.net/isset">isset</a> function. <code>isset</code>, used on an <code>ArrayAccess</code> object, will call its method <code>offsetExists</code>. This method returns a boolean: whether the offset exists or not.</p>
<p>If we implement <code>offsetExists</code> this way, we can use <code>isset</code> to check if an array has a key, including the ones associated with <code>null</code> values:</p>
<pre class="php code">
// $this->aRow is a real array stored as a protected property of the object

public function offsetExists($offset)
{
	return array_key_exists($offset, $this->aRow);
}
</pre>
<p>Using <code>isset</code> on an <code>ArrayAccess</code> object that implements this function will give the same result as using <code>array_key_exists</code> directly on the object. Example:</p>
<pre class="php code">
$o = new myArrayAccessClass;
$a = array();

// isset, used on an ArrayAccess object...
echo (int)isset($o['key']);
// ... is the same as array_key_exists used on a real array
echo (int)array_key_exists('key', $a);
</pre>
<p>We also added an <a href="http://wee.extend.ws/browser/trunk/tools/tests/basic/arrays.php">unit test</a> about this in our framework. Never knows, maybe <code>array_key_exists</code> is going to accept <code>ArrayAccess</code> objects in the future.</p>
<h2>The Ugly</h2>
<p>Well, I&#8217;m sure you can begin to see the ugly in this: <code>isset</code> giving the same results as <code>array_key_exists</code> on <code>ArrayAccess</code> objects, but different results on real arrays. That means needing to pay more attention to what you actually use these functions on.</p>
<p>Another ugly result is that you will need to do 2 tests when you accept both arrays and objects. If you received an array you&#8217;ll have to use <code>array_key_exists</code>, otherwise <code>isset</code>. This results in the following conditional statement:</p>
<pre class="php code">
if ((is_array($m) &#038;&#038; array_key_exists($sKey, $m)) || (!is_array($m) &#038;&#038; isset($m[$sKey])))
	; // insert code here...
</pre>
<p>Take care about these issues next time you use ArrayAccess!</p>
<p>Thanks for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.extend.ws/2008/03/01/arrayaccess-quirks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Extending SimpleXML</title>
		<link>http://blog.extend.ws/2008/02/20/extending-simplexml/</link>
		<comments>http://blog.extend.ws/2008/02/20/extending-simplexml/#comments</comments>
		<pubDate>Wed, 20 Feb 2008 21:22:56 +0000</pubDate>
		<dc:creator>Loïc Hoguin</dc:creator>
				<category><![CDATA[PHP5]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web:Extend]]></category>

		<guid isPermaLink="false">http://blog.extend.ws/2008/02/20/extending-simplexml/</guid>
		<description><![CDATA[PHP5 introduced the SimpleXML extension. It allows for easy manipulation of XML documents. This nice extension received a warm welcome in the community. But it unfortunately has its drawbacks.
The Problem
SimpleXML uses some little hacks to do its tricks. It overloads the -> and [] operators. What that means is that if you extend SimpleXML and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://php.net">PHP5</a> introduced the <a href="http://php.net/simplexml">SimpleXML extension</a>. It allows for easy manipulation of XML documents. This nice extension received a warm welcome in the community. But it unfortunately has its drawbacks.</p>
<h2>The Problem</h2>
<p>SimpleXML uses some little hacks to do its tricks. It overloads the <code>-></code> and <code>[]</code> operators. What that means is that if you extend SimpleXML and create a property in the child class, you will never be able to access this property, because SimpleXML will return a child node and ignore your property. You cannot either use the <code>ArrayAccess</code> interface to store your properties since SimpleXML already overload the <code>[]</code> operator to allow you to access the node&#8217;s attributes.</p>
<p>Why would you extend SimpleXML if you can&#8217;t set any property? Well you can of course add a few methods, to add missing functionality for example. But that&#8217;s about it. No properties. If you need to associate a SimpleXML node with a variable you must either create a child node, or create an attribute. Problem is, it won&#8217;t work with objects, arrays or resources.</p>
<p>Someone already <a href="http://www.oliverbrown.me.uk/2005/09/03/extending-simplexml/">tried to do it</a>. Sorry Oliver Brown, but I don&#8217;t like <a href="http://www.oliverbrown.me.uk.nyud.net/exml.phps">your solution</a>. I shall thank you however, since you allowed me to find a better way to do it. I&#8217;m sorry about not telling the world sooner about all this.</p>
<h2>The Solution</h2>
<p>The solution is currently available in the <a href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL licensed</a> <a href="http://wee.extend.ws">Web:Extend framework</a>, in the form of the <a href="http://wee.extend.ws/browser/trunk/wee/xml/weeSimpleXMLHack.class.php?rev=247">weeSimpleXMLHack class</a>. Although LGPL licensed, I (the original author) allow you to copy and paste this specific class in your project whatever the license is. In return, please just refer to this post in your code.</p>
<p>For your convenience I will paste the code below.</p>
<pre class="php code">
/**
	Extends SimpleXMLIterator to allow the setting and getting of properties.
	Properties must be accessed using the function property since -> is already used by SimpleXMLIterator
	(and its parent class SimpleXMLElement).
*/

class weeSimpleXMLHack extends SimpleXMLIterator
{
	/**
		Return the uniqid string for this object.

		@return The uniqid string.
	*/

	protected function hack()
	{
		if (empty($this['weeuniqidhack']))
			$this['weeuniqidhack'] = uniqid();
		return (string)$this['weeuniqidhack'];
	}

	/**
		Set or get a property of a SimpleXMLIterator object.

		@param	$sName	The name of the property.
		@param	$mParam The variable to attach to this element. If null it is not attached.
		@return	mixed	The variable attached with the specified name.
	*/

	public function property($sName, $mParam = null)
	{
		static $aProperties = null;

		if (!is_null($mParam))
			$aProperties[$this->hack()][$sName] = $mParam;

		if (!array_key_exists($sName, $aProperties[$this->hack()]))
			throw new IllegalStateException("The property doesn't exist.");

		return $aProperties[$this->hack()][$sName];
	}
}
</pre>
<p><em>If you compare this code and the original code from the framework you will notice a few differences. I&#8217;ve edited it a bit to make it more readable for people that do not know how the <code>fire</code> function works.</em></p>
<p>So how does it work? Well as you know you can create a method. In this method you can create a <a href="http://php.net/manual/en/language.variables.scope.php#language.variables.scope.static">static variable</a> that will be accessible only by the code in the method. Make this variable an array of properties. By making the method usable both as a getter and a setter you can set and get properties from this static array.</p>
<p>But that&#8217;s not enough. As you might already know, a static variable declared in a method will keep the same value for all the objects of the class. That is, if object #1 sets a static variable value to 1, then object #2 sets it to 2, it will have a value of 2 when object #1 tries to access it again. We do not want that since we want to be able to associate objects and more to our SimpleXML objects.</p>
<p>That&#8217;s where <code><a href="http://php.net/uniqid">uniqid</a></code> comes. <code>uniqid</code> creates a completely unique identifier. Great! We can now assign an unique identifier to each of our SimpleXML objects, and use that identifier to retrieve the properties of that object. We only call <code>uniqid</code> once and store it as a reserved attribute named <code>weeuniqidhack</code>. When the <code>property</code> method is called we can just get that identifier and do a get or a set on our static array without fearing conflicts with other SimpleXML objects properties.</p>
<p>You can now use this class by calling <code>simplexml_load_string</code> or <code>simplexml_load_file</code> and giving the class name, <code>'weeSimpleXMLHack'</code>, as the second parameter:</p>
<pre class="php code">
$oNode = simplexml_load_file('/path/to/my/file.xml', 'weeSimpleXMLHack');
</pre>
<p>This hack was used for more than a year in the <a href="http://wee.extend.ws">Web:Extend framework</a> and worked since the early releases of PHP5, so you can use it without any fear. The only drawback is that an attribute must be sacrificed to store the unique identifier.</p>
<p>I have other tips to share but they will be for another day. You might find some by <a href="http://wee.extend.ws/browser">browsing the framework&#8217;s code</a>.</p>
<p>Thanks for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.extend.ws/2008/02/20/extending-simplexml/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

