<?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>devexp &#187; php</title>
	<atom:link href="http://www.devexp.eu/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devexp.eu</link>
	<description>DEVelopment EXPerience, shared with the world!</description>
	<lastBuildDate>Fri, 28 Oct 2011 12:07:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to use a symfony 1 layout from a different directory</title>
		<link>http://www.devexp.eu/2011/10/28/how-to-use-a-symfony-1-layout-from-a-different-directory/</link>
		<comments>http://www.devexp.eu/2011/10/28/how-to-use-a-symfony-1-layout-from-a-different-directory/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 11:48:36 +0000</pubDate>
		<dc:creator>Van de Voorde Toni</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Layout]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.devexp.eu/?p=1042</guid>
		<description><![CDATA[In symfony 1 it is possible to have different layouts for an application. But they all have to be put into the directory &#8216;myproject/apps/frontend/templates/&#8217;. But what if you want to use a layout from another location? Assume you make a &#8230; <a href="http://www.devexp.eu/2011/10/28/how-to-use-a-symfony-1-layout-from-a-different-directory/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.devexp.eu/wp-content/uploads/2009/04/symfony.jpg"><img src="http://www.devexp.eu/wp-content/uploads/2009/04/symfony.jpg" alt="" title="Symfony" width="127" height="35" class="alignright size-full wp-image-727" /></a>In symfony 1 it is possible to have different layouts for an application. But they all have to be put into the directory &#8216;myproject/apps/frontend/templates/&#8217;. But what if you want to use a layout from another location? </p>
<p>Assume you make a plugin with a specific layout, it would be nice to load the layout from the plugin directory, and not to have to copy the file to the global directory.</p>
<p>Here is how you can achieve this:</p>
<pre class="brush: php; title: ; notranslate">
$template = $this-&gt;getContext()-&gt;getConfiguration()-&gt;getTemplateDir('MODULE', 'LAYOUT_FILE.php');
$this-&gt;setLayout($template . '/LAYOUT_FILE');
</pre>
<p>Let&#8217;s say you have the following:</p>
<pre class="brush: plain; title: ; notranslate">
my_project/
  plugins/
    my_plugin/
      modules/
        MyUser/
          actions/
            actions.php
          templates/
            indexSuccess.php
            MyUserLayout.php
</pre>
<p>The actions.php class could be something like this:</p>
<pre class="brush: php; title: ; notranslate">
class MyUserAction extends sfActions {

  public function preExecute() {
    $template = $this-&gt;getContext()-&gt;getConfiguration()-&gt;getTemplateDir('MyUser', 'MyUserLayout.php');

    $this-&gt;setLayout($template . '/MyUserLayout');
  }

  public function executeIndex() {

  }
}
</pre>
<p>Have fun!</p>
<div class="shr-publisher-1042"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.devexp.eu/2011/10/28/how-to-use-a-symfony-1-layout-from-a-different-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to force symfony colors on windows with PuttyCyg?</title>
		<link>http://www.devexp.eu/2009/09/22/how-to-force-symfony-colors-on-windows-with-cygwinputtycyg/</link>
		<comments>http://www.devexp.eu/2009/09/22/how-to-force-symfony-colors-on-windows-with-cygwinputtycyg/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 13:18:14 +0000</pubDate>
		<dc:creator>Van de Voorde Toni</dc:creator>
				<category><![CDATA[Framework]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.devexp.eu/?p=936</guid>
		<description><![CDATA[Those of you who’re developing with symfony under windows will have noticed that, when running tasks in the command prompt, no colors are used. This is because the windows command prompt isn’t compatible with the color notation. Most of you &#8230; <a href="http://www.devexp.eu/2009/09/22/how-to-force-symfony-colors-on-windows-with-cygwinputtycyg/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Those of you who’re developing with symfony under windows will have noticed that, when running tasks in the command prompt, no colors are used. This is because the windows command prompt isn’t compatible with the color notation.<br />
Most of you also have <a href="http://www.cygwin.com/">cygwin</a> installed (shame on you if you didn’t :p). But even if you run the tasks through “<a href="http://code.google.com/p/puttycyg/">PuttyCyg</a>”, which is fully compatible with the color notation, you will not benefit from the colors. </p>
<p>Why?</p>
<p><span id="more-936"></span><br />
The problem resides in the symfony class “sfAnsiColorFormatter” in the method “supportsColors($stream)”:</p>
<pre class="brush: php; title: ; notranslate">
  /**
   * Returns true if the stream supports colorization.
   *
   * Colorization is disabled if not supported by the stream:
   *
   *  -  windows
   *  -  non tty consoles
   *
   * @param mixed $stream A stream
   *
   * @return Boolean true if the stream supports colorization, false otherwise
   */
  public function supportsColors($stream)
  {
    return DIRECTORY_SEPARATOR != '\\' &amp;&amp; function_exists('posix_isatty') &amp;&amp; @posix_isatty($stream);
  }
</pre>
<p>The method supportsColors($stream) decides whether or not colors are supported. And as you can see, one of the checks is the directory separator which in our case will always return false because we are on a windows operating system. So even if you run tasks through puttycyg the directory separator will remain the same.</p>
<p><strong>Possibility 1</strong></p>
<p>If you always work through the puttycyg you could simply set the method to always return true, but in a command prompt it will look like this:<br />
<div id="attachment_946" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devexp.eu/wp-content/uploads/2009/09/command_output.png"><img src="http://www.devexp.eu/wp-content/uploads/2009/09/command_output-300x236.png" alt="Dos Command Output" title="Dos Command Output" width="300" height="236" class="size-medium wp-image-946" /></a><p class="wp-caption-text">Dos Command Output</p></div></p>
<p><strong>Possibility 2</strong></p>
<p>Detect if cygwin is used. This way when you use the dos command the output will work and when cygwin is used you&#8217;ll have the colors <img src='http://www.devexp.eu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>I checked the $_SERVER array to find something that could help me to distinguish the cygwin prompt with the dos prompt, and I found that the &#8216;PWD&#8217; key is only available on *nix shells. And when I print the value of $_SERVER['PWD'] in the cygwin prompt it gives me &#8220;/cygdrive/f/sandbox/adlogix/branch-3.2/frontend&#8221;. </p>
<p>Knowing that, here is how we can change the supportsColors method:</p>
<pre class="brush: php; title: ; notranslate">
  /**
   * Returns true if the stream supports colorization.
   *
   * Colorization is disabled if not supported by the stream:
   *
   *  -  windows
   *  -  non tty consoles
   *
   * @param mixed $stream A stream
   *
   * @return Boolean true if the stream supports colorization, false otherwise
   */
  public function supportsColors($stream)
  {
    $supported = DIRECTORY_SEPARATOR != '\\' &amp;&amp; function_exists('posix_isatty') &amp;&amp; @posix_isatty($stream);

    return $supported ? true : !is_bool(strpos(@$_SERVER['PWD'], &quot;/cygdrive&quot;));
  }
</pre>
<p>What I did, is still using the check symfony used, but when it returns false I do a second check to see if the $_SERVER['PWD'] exists and that it contains the String &#8220;/cygdrive&#8221;.</p>
<p>Now when I run the taks through cygwin I get the colors and when I run it in dos it displays correctly.<br />
<div id="attachment_950" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devexp.eu/wp-content/uploads/2009/09/puttycyg-versus-dos.png"><img src="http://www.devexp.eu/wp-content/uploads/2009/09/puttycyg-versus-dos-300x187.png" alt="PuttyCyg versus Dos" title="PuttyCyg versus Dos" width="300" height="187" class="size-medium wp-image-950" /></a><p class="wp-caption-text">PuttyCyg versus Dos</p></div></p>
<p>I only tested it on my machine, so if you have troubles or a better way to do it, please let me know <img src='http://www.devexp.eu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p><strong>Update:</strong> This is only tested with symfony 1.2 and as from sf 1.3 there will be an option &#8211;color to force the colors.</p>
<p><strong>Update:</strong> For some reason it does not work in the cygwin bash shell. When I set the message manually (echo -e &#8220;\033[31mHello World\033[0m&#8221;) in the command the colors appear, but through symfony not.  I suspect that the cygwin bash shell miss interprets the returns of php, but I have no idea why it does work on puttyCyg (which only launches the cygwin shell) &#8230; probably some startup configuration of the bash ?!</p>
<div class="shr-publisher-936"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.devexp.eu/2009/09/22/how-to-force-symfony-colors-on-windows-with-cygwinputtycyg/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Interview: Stefan Koopmanschap</title>
		<link>http://www.devexp.eu/2009/09/22/interview-stefan-koopmanschap/</link>
		<comments>http://www.devexp.eu/2009/09/22/interview-stefan-koopmanschap/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 06:24:18 +0000</pubDate>
		<dc:creator>van Rumste Kenneth</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Interview]]></category>
		<category><![CDATA[Koopmanschap]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Stefan]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.devexp.eu/?p=928</guid>
		<description><![CDATA[A few weeks ago I thought it might be cool to get some interesting guys, which are occupied with projects in PHP, interviewed. And guess what, we got on contact with Mr. Stefan Koopmanschap and he was kind enough to &#8230; <a href="http://www.devexp.eu/2009/09/22/interview-stefan-koopmanschap/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><img class="alignright size-full wp-image-977" style="border: 0pt none; margin: 5px;" title="3317597132_6be12c93c7" src="http://www.devexp.eu/wp-content/uploads/2009/09/3317597132_6be12c93c7.jpg" alt="3317597132_6be12c93c7" width="160" height="240" /></p>
<p>A few weeks ago I thought it might be cool to get some interesting guys, which are occupied with projects in PHP, interviewed. And guess what, we got on contact with Mr. Stefan Koopmanschap and he was kind enough to answer all our questions.</p>
<blockquote><p>Stefan Koopmanschap (&#8216;left&#8217;) is a PHP developer, consultant and trainer with an eye for best practices. He works at <a href="http://www.unet.nl/" target="_blank">Unet</a> as (symfony) developer and development team leader. He is a community person and is active in the european PHP community as secretary of the <a href="http://www.phpbenelux.eu/" target="_blank">phpBenelux</a> Usergroup as well as in the Symfony community by advocating symfony and as the Community Manager.</p>
<p>Stefan has a wide history in Open Source, having been Support Team Leader for phpBB, documentation translator for Zend Framework and community manager, plugin developer and maintainer plus various other things for symfony.</p>
<p>Stefan is also a best practices advocate. He prefers easy and useful explanations of best practices over the academic and theoretical stuff found in most literature.</p></blockquote>
<p>Hope you enjoy this interview!</p>
<p><strong>Hello Stefan, first of all, thx for taking the time to answer all our questions.</strong></p>
<p><strong>Can you tell us what projects you are currently working on?</strong></p>
<p>At work I am involved in a big project to build an application that will handle all the administration, provisioning and handling of user accounts etc. for the whole VOiP and connectivity of the services we offer. Aside from that, my main projects are being the Community Manager for symfony and also preparing some new talks for the upcoming conferences.</p>
<p><span id="more-928"></span></p>
<p><strong>What technologies will become important in your line of work in the<br />
near future?</strong></p>
<p>Obviously, a big part of my life is currently being ruled by Symfony. It is the framework we use at my work, and because of my involvement in the project it also rules a big part of my private time. Also, other frameworks (such as Zend Framework) take a part of my life for projects I&#8217;m working on. For one of my personal development projects I&#8217;m also looking into jobqueue/message servers such as <a href="http://www.dropr.org/" target="_blank">Dropr </a>and <a href="http://www.gearman.org/" target="_blank">Gearman</a>. And of course I&#8217;m always reading into new technologies to know what they can do, so I can apply that knowledge at a later date.</p>
<p><strong>How did you get the knowledge you master today? Where there seminars, lessons, people, self education or other ways important to become who you are today?</strong></p>
<p>I have no Computer Science background, most of my current knowledge is self-taught or I picked up through experience over the years. Sometimes this is a good thing but often this has been a problem since over the years I have reinvented the wheel. Reading about design patterns for instance I often found out the things I &#8220;invented&#8221; were really thought about way before me by much smarter people who also considered many more things that I had considered. But by reading about many of these topics and best practices, I&#8217;ve picked up quite a bit of knowledge over the years. Combine that with the variation of projects I&#8217;ve been involved in and you get the knowledge and experience I&#8217;ve picked up.</p>
<p><strong>Do you consider yourself a lucky guy or did you earn all your  success because of yourself?<br />
</strong><br />
A bit of both. I&#8217;ve obviously done a lot of work to get to the point where I am right now, yet I also consider myself a lucky guy. The amount of conferences I get accepted to speaking at these days allows me to travel around the world and meet the brightest minds of the PHP community. I&#8217;ve gotten a lot of help, pointers, code reviews etc by people from the community that helped me improve myself. Many of these I did not ask for, yet I&#8217;ve found it very helpful.</p>
<p><strong>What environment do you work on and what applications are important to  you?</strong></p>
<p>My personal preference is Apple computers with OSX. That environment allows me to work in the most efficient way. A good second choice, and the one I currently use at work, is an Ubuntu linux environment running KDE. The applications I run to help me in my work are an IDE (Zend Studio is my personal favorite), a MySQL frontend (phpMyAdmin is what I usually use), a webserver (Apache) with PHP installed with Xdebug. The main framework of choice would be symfony, with the help of additional components from Zend Framework, PEAR and ezComponents.</p>
<p><strong>If you could start over again from the moment you left high school,  what would you do different?</strong></p>
<p>I would do at least part-time study computer sciences to give me a better theoretical base on the development concepts I work with on a daily basis. But the thing that helps me most is the experience I built up over the years, so aside from that; I would not really do many things in a different way.</p>
<p><strong>Do you have any special hobbies or interests?</strong></p>
<p>Aside from PHP and Open Source, I like listening to music and read books.</p>
<p><strong>What are your plans for 2010 or the future in general?<br />
</strong><br />
I want to keep promoting best practices, and hope to improve the general level of knowledge in the PHP community.</p>
<p><strong>Quick answers, just answer in  max 5 words  when you read these words:</strong><br />
<strong>1.      IE</strong> &#8211; the bane of my existence<br />
<strong>2.      Apple </strong>- the ultimate operating system<br />
<strong>3.      Twitter</strong> &#8211; great communication and network channel<br />
<strong>4.      Face book</strong> &#8211; interesting platform<br />
<strong>5.      Analyze</strong> &#8211; important phase of any project<br />
<strong>6.      Layout</strong> &#8211; I&#8217;m more a back end guy<br />
<strong>7.      Religion</strong> &#8211; The root of all evil<br />
<strong>8.      Programming </strong>- Fantastic source of joy<br />
<strong>9.      Internet</strong> &#8211; Greatest invention ever</p>
<div class="shr-publisher-928"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.devexp.eu/2009/09/22/interview-stefan-koopmanschap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>new PHP meeting</title>
		<link>http://www.devexp.eu/2009/06/17/new-php-meeting/</link>
		<comments>http://www.devexp.eu/2009/06/17/new-php-meeting/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 13:31:59 +0000</pubDate>
		<dc:creator>van Rumste Kenneth</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[mons]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpbelgium]]></category>

		<guid isPermaLink="false">http://www.devexp.eu/?p=830</guid>
		<description><![CDATA[PHPBelgium is pleased to announce our first meeting in Mons! Date:  24/06/2009 19:30 &#8211; 23:00 Location: ISIMs, Mons, Belgium The event will be recorded and available in live streaming on this url: www.isims.be/phpbelgium.html If this link wouldn&#8217;t work, more information &#8230; <a href="http://www.devexp.eu/2009/06/17/new-php-meeting/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>PHPBelgium is pleased to announce our first meeting in Mons!</p>
<div>
<div>Date:  <span>24/06/2009 <span>19:30</span><span> &#8211; </span><span>23:00</span></span></div>
</div>
<div>
<div>Location: ISIMs, Mons, Belgium</div>
</div>
<p>The event will be recorded and available in live streaming on this url: <a href="http://www.isims.be/phpbelgium.html" target="_blank">www.isims.be/phpbelgium.html</a></p>
<p>If this link wouldn&#8217;t work, more information can be found on the website of <a href="http://www.campusnumerique.be/actualites/conference-de-php-belgium-a-mons.html" target="_blank">CampusNumerique</a></p>
<p><strong>Schedule</strong>:<br />
<span style="text-decoration: underline;">19:30h</span> Welcome &amp; drink<br />
<span style="text-decoration: underline;">20:00h</span> PHP &amp; the MVC Pattern &#8211; Patrick Allaert<br />
Patrick Allaert is Competence Center Architect at AUSY where he brings 10 years of PHP development experience. Patrick is also known by the community for developing APM as well as evangelizing for Free and Open Source Software<br />
<span style="text-decoration: underline;">21:00h </span>Break<br />
<span style="text-decoration: underline;">21:10h</span> PHP 5.3: new features &#8211; Davide Mendolia<br />
Davide is a veteran PHP developer working at AUSY as a PHP Software Architect. In his spare time, Davide works on APM too as well as contributing to the PHP project with benchmarking tests<br />
<span style="text-decoration: underline;">22:00h</span> Quizz to win goodies/conference tickets<br />
<span style="text-decoration: underline;">22:15h</span> Socializing and networking</p>
<div class="shr-publisher-830"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.devexp.eu/2009/06/17/new-php-meeting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mantis in Eclipse with Mylyn</title>
		<link>http://www.devexp.eu/2009/05/20/mantis-in-eclipse-with-mylyn/</link>
		<comments>http://www.devexp.eu/2009/05/20/mantis-in-eclipse-with-mylyn/#comments</comments>
		<pubDate>Wed, 20 May 2009 07:53:06 +0000</pubDate>
		<dc:creator>van Rumste Kenneth</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[mantis]]></category>
		<category><![CDATA[mylyn]]></category>
		<category><![CDATA[websvn]]></category>

		<guid isPermaLink="false">http://www.devexp.eu/?p=783</guid>
		<description><![CDATA[This is a post especially for those who use Mantis as a bug tracker software and Eclipse as development software. For our PHP and JAVA development we do all the programming in Eclipse and wouldn&#8217;t it be easy if Eclipse &#8230; <a href="http://www.devexp.eu/2009/05/20/mantis-in-eclipse-with-mylyn/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>This is a post especially for those who use Mantis as a bug tracker software and Eclipse as development software. For our PHP and JAVA development we do all the programming in Eclipse and wouldn&#8217;t it be easy if Eclipse recognized the bugs we are working? Wouldn&#8217;t it be easy if we could just get an automatic link between mantis and the commits we do in subversion (svn).</p>
<p>Well, praise the lord, &#8217;cause there is an open source project out there that does all these things called <a href="http://www.eclipse.org/mylyn/" target="_blank">Mylyn</a>.</p>
<blockquote><p>Mylyn is a task-focused interface for Eclipse that reduces information overload and makes multi-tasking easy. It does this by making tasks a first class part of Eclipse, and integrating rich and offline editing for repositories such as Bugzilla, Trac, and JIRA.  Once your tasks are integrated, Mylyn monitors your work activity to identify relevant information, and uses this task context to focus the user interface on the task-at-hand. This puts the information you need at your fingertips and improves productivity by reducing searching, scrolling, and navigation. By making task context explicit Mylyn also facilitates multitasking, planning, reusing past efforts, and sharing expertise.
</p></blockquote>
<p><img class="alignright wp-image-786" title="tasklist-splash-31" src="http://www.devexp.eu/wp-content/uploads/2009/05/tasklist-splash-31.png" alt="tasklist-splash-31" width="282" height="489" /><br />
After a quick install and doing the configuration in Eclipse the interface is installed in Eclipse and ready to work with. And it is great! Easy overviews of all the bugs sorted by filter as you personally prefer, great layout to create and manage the bugs, etc.</p>
<p>It communicates quite nice with mantis, it could be a bit faster but let&#8217;s not fall over that tiny thing. The cool thing though is when working for a specific bug, all changes will be committed on those files with a reference to that specific bug. This makes it very easy to get see what files where changed for a specific bug. </p>
<p>For example when you commit changed files you will be asked to comment your committed files. Mylyn links your files directly to the current bug you are working on and puts this in the comment area: &#8220;fixed issue #178: Change user name to full name&#8221; . The number of the issue and the state are first mentioned and the title completes your comment.</p>
<p>In the screenshot you can see how a bug can be inserted or edited in a easy layout and inside the eclipse environment. Click on the image or <a href="http://www.devexp.eu/wp-content/uploads/2009/05/mylyn-31-screenshot.png" target="_blank">here</a> to see a larger image<br />
<a href="http://www.devexp.eu/wp-content/uploads/2009/05/mylyn-31-screenshot.png" target="_blank"><img class="size-full wp-image-785" title="mylyn-31-screenshot" src="http://www.devexp.eu/wp-content/uploads/2009/05/mylyn-31-screenshot.png" alt="mylyn-31-screenshot" width="550" border="0"/></a></p>
<p>My colleague Toni also installed <a href="http://www.websvn.info/" target="_blank">WebSVN </a>that gives us a super overview on all those changes and files committed in subversion.</p>
<p>If you use Mantis and Eclipse and SVN I highly recommend that you use these two utilities.</p>
<div class="shr-publisher-783"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.devexp.eu/2009/05/20/mantis-in-eclipse-with-mylyn/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>TestFest 2009</title>
		<link>http://www.devexp.eu/2009/05/08/testfest-2009/</link>
		<comments>http://www.devexp.eu/2009/05/08/testfest-2009/#comments</comments>
		<pubDate>Fri, 08 May 2009 09:26:08 +0000</pubDate>
		<dc:creator>van Rumste Kenneth</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Combell]]></category>
		<category><![CDATA[fest]]></category>
		<category><![CDATA[Gent]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[TestFest]]></category>
		<category><![CDATA[utrecht]]></category>

		<guid isPermaLink="false">http://www.devexp.eu/?p=667</guid>
		<description><![CDATA[Tomorrow on the 9th of may an event called &#8216;PHP TestFest 2009&#8242; will take place in the offices of Combell. (visit the website) What is TestFest you ask? The TestFest is an event that aims at improving the code coverage &#8230; <a href="http://www.devexp.eu/2009/05/08/testfest-2009/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Tomorrow on the 9th of may an event called &#8216;PHP TestFest 2009&#8242; will take place in the offices of Combell. (<a href="http://qa.php.net/testfest.php" target="_blank">visit the website</a>)</p>
<p><strong>What is TestFest you ask?</strong></p>
<blockquote><p>The TestFest is an event that aims at improving the <a href="http://gcov.php.net/">code coverage</a> of the <a href="http://qa.php.net/running-tests.php">test suite</a> for the PHP language itself. As part of this event, local User Groups (UG) are invited to join the TestFest. These UGs can meet physically or come together virtually. The point however is that people network to learn together. Aside from being an opportunity for all of you to make friends with like minded people in your (virtual) community, it also will hopefully reduce the work load for the PHP.net mentors. All it takes is someone to organize a UG to spearhead the event and to get others involved in <a href="http://qa.php.net/write-test.php">writing phpt tests</a>. The submissions will then be reviewed by members of php.net before getting included in the official test suite.</p></blockquote>
<p>This event will take place in different countries but for the dutch speaking PHP community you can go to these addresses:</p>
<p>Hogeschool Domstad, Koningsbergerstraat 9, 3531 AJ Utrecht,The Netherlands<img class="size-thumbnail wp-image-764 alignright" style="margin: 5px;" title="testfest_big-276x300" src="http://www.devexp.eu/wp-content/uploads/2009/05/testfest_big-276x300-150x150.png" alt="testfest_big-276x300" width="150" height="150" /></p>
<p>And</p>
<p>Combell offices Ghent, Skaldenstraat 121, 9042 Gent, Belgium (<a href="http://upcoming.yahoo.com/event/2472669/" target="_blank">more info</a>)</p>
<p>There will be a workshop to get the needed information and then it&#8217;s your turn to contribute to the development of the PHP language.</p>
<p>Felix De Vliegher is the mentor for Belgium and did the most tests in 2008 in the whole freaking world. With his experience and vision, this will be a piece of cake, be there or be square&#8230;. (maybe I will write about Felix later in our topic interesting people)</p>
<p>For those who will be on this event, have fun!!!!</p>
<div class="shr-publisher-667"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.devexp.eu/2009/05/08/testfest-2009/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Symfony Form: unsetAllFieldsExcept()</title>
		<link>http://www.devexp.eu/2009/04/27/symfony-form-unsetallfieldsexcept/</link>
		<comments>http://www.devexp.eu/2009/04/27/symfony-form-unsetallfieldsexcept/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 12:37:31 +0000</pubDate>
		<dc:creator>Van de Voorde Toni</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[form]]></category>

		<guid isPermaLink="false">http://www.devexp.eu/?p=706</guid>
		<description><![CDATA[When creating forms in symfony which extends from a Base (ORM) class, you sometimes do not need all fields that Propel/Doctrine generates for you. If you want to remove them you have several ways to do so. 1. Unset the &#8230; <a href="http://www.devexp.eu/2009/04/27/symfony-form-unsetallfieldsexcept/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>When creating forms in symfony which extends from a Base (ORM) class, you sometimes do not need all fields that Propel/Doctrine generates for you. If you want to remove them you have several ways to do so.</p>
<p><b>1. Unset the fiels you don&#8217;t need.</b></p>
<pre class="brush: php; title: ; notranslate">
public function configure() {
  unset($this['field1'], $this['field2'], ... );
}
</pre>
<p>Simple way to remove the fields you don&#8217;t want, but if you change something in your database, which has an impact on that form (new column, foreignkey, etc ), it will be added in the (generated) super class. And if you don&#8217;t update the unset function with that extra field, it will be expected in the form. Unless you have unit tests for all your forms this could brake it without knowing it.</p>
<p><b>2. Override the setup function.</b></p>
<pre class="brush: php; title: ; notranslate">
/**
 * @override
 */
public function setup()
  {
    parent::setup();

    $this-&gt;setWidgets(...);

    $this-&gt;setValidators(...);
  }
</pre>
<p>Another way is to override the setup function and do your own widgets and validators initialization. This is a good way to only intialize the fields you really need, but you&#8217;ll have to do what your ORM generated for you.</p>
<p><b>3. Use a function which unsets all fields except the one you need (like the enableAllPluginsExcept function).</b></p>
<pre class="brush: php; title: ; notranslate">
$this-&gt;unsetAllFieldsExcept(array(
      'field1',
      'field2',
      'field3',
      ...));
</pre>
<p>This would be usefull, because it will remove all fields you do not want to use, and even if new fields are added it will not use them. The drawback is that if you have 20 fields and only need to unset one of them, you&#8217;ll have more type work <img src='http://www.devexp.eu/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .<br />
Since it does not exist in symfony, I quickly created our own function. This function should be added in the class <u><em>BaseFormPropel.class</em></u>:</p>
<pre class="brush: php; title: ; notranslate">
abstract class BaseFormPropel extends sfFormPropel
{
  public function setup() {
  }

  protected function unsetAllFieldsExcept($fields = array()) {

    $unsetFields = array_diff(array_keys($this-&gt;getWidgetSchema()-&gt;getFields()), $fields);

    foreach($unsetFields as $value) {
      unset($this[$value]);
    }
  }
}
</pre>
<p><b>Which one to use ?</b><br />
None of them are better. But if you need to reset a majority of the fields the ORM has generated then I would go for the method 2. If you only need to unset the fields you do not want to use then I would use the function unsetAllFieldsExcept().</p>
<p>Which method do/would you use ?</p>
<div class="shr-publisher-706"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.devexp.eu/2009/04/27/symfony-form-unsetallfieldsexcept/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>sfWidgetFormInputCheckbox unchecked bug</title>
		<link>http://www.devexp.eu/2009/04/23/sfwidgetforminputcheckbox-unchecked-bug/</link>
		<comments>http://www.devexp.eu/2009/04/23/sfwidgetforminputcheckbox-unchecked-bug/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 12:33:37 +0000</pubDate>
		<dc:creator>Van de Voorde Toni</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[sfWidgetFormInputCheckbox]]></category>

		<guid isPermaLink="false">http://www.devexp.eu/?p=681</guid>
		<description><![CDATA[Ever tried to create a Symfony form with a check box input field, which by default should be unchecked ? No ? Well read on because it&#8217;s not that easy . This would be the code to print a check &#8230; <a href="http://www.devexp.eu/2009/04/23/sfwidgetforminputcheckbox-unchecked-bug/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Ever tried to create a Symfony form with a check box input field, which by default should be unchecked ? No ? Well read on because it&#8217;s not that easy <img src='http://www.devexp.eu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>This would be the code to print a check box input field in a Symfony form:</p>
<pre class="brush: php; title: ; notranslate">
class CheckboxForm extends BaseCheckboxForm {
 public function configure() {
 $this-&gt;widgetSchema['field'] = new sfWidgetFormInputCheckbox();
 }
}
</pre>
<p>When you use the form to create something then by default the check box should be unchecked. And when you use this form for editing, then the check box should be checked if the object you try to edit has already been checked in the past.</p>
<p>If you try this code, you&#8217;ll see that the check box will always be checked. Even if you display this form to create a new object. Strange no ?</p>
<p><span id="more-681"></span></p>
<p>The problem is due to a bug in the Symfony sfWidgetFormInputCheckbox class. Even worse, this bug has been reported the first time 10 months ago (<a href="http://trac.symfony-project.org/ticket/3917" target="_blank">trac #3917</a>) and 1 month later (<a href="http://trac.symfony-project.org/ticket/3996" target="_blank">trac #3996</a>) and it&#8217;s still not fixed ! (grrrrr)</p>
<p>Until Symfony bug fixes this issue, there are 2 work a rounds you can use.</p>
<p><strong>1. Edit the sfWidgetFormInputCheckbox class and patch it:</strong></p>
<p><em>actual</em></p>
<pre class="brush: php; title: ; notranslate">
class sfWidgetFormInputCheckbox extends sfWidgetFormInput
{
 ...
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
 if (!is_null($value) &amp;&amp; $value !== false)
 {
 $attributes['checked'] = 'checked';
 }
 ...
 }
}
</pre>
<p><em>patched</em></p>
<pre class="brush: php; title: ; notranslate">
class sfWidgetFormInputCheckbox extends sfWidgetFormInput
{
 ...
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
 if (!is_null($value) &amp;&amp; $value !== false &amp;&amp; $value != 0)
 {
 $attributes['checked'] = 'checked';
 }
 ...
 }
}
</pre>
<p>I would not recommend this, because if like us, you have more than one Symfony environment, there is a chance that you could forget to patch it. And worse if Symfony releases a new version without the bug fix you&#8217;ll have to remember to re patch the file.</p>
<p><strong>2. Extend the sfWidgetFormInputCheckbox class and override the render method:</strong></p>
<p><em>Edit: Put this class in the lib folder and call it myOwnWidgetFormInputCheckbox.class.php. After that run symfony cc.</em></p>
<pre class="brush: php; title: ; notranslate">
/**
 * FIXME: This class can be removed if the sfWidgetFormInputCheckbox bug
 * has been resolved in symfony.
 */
class myOwnWidgetFormInputCheckbox extends sfWidgetFormInputCheckbox
{
 /**
 * Override render method due to symfony bug (http://trac.symfony-project.org/ticket/3917)
 */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
 if (!is_null($value) &amp;&amp; $value !== false &amp;&amp; $value != 0)
 {
 $attributes['checked'] = 'checked';
 } 

 if (!isset($attributes['value']) &amp;&amp; !is_null($this-&gt;getOption('value_attribute_value'))) {
 $attributes['value'] = $this-&gt;getOption('value_attribute_value');
 }

 return parent::render($name, null, $attributes, $errors);
 }
}
</pre>
<p>Your form class should then be changed to:</p>
<pre class="brush: php; title: ; notranslate">
class CheckboxForm extends BaseCheckboxForm {
 public function configure() {
 $this-&gt;widgetSchema['field'] = new myOwnWidgetFormInputCheckbox();
 }
}
</pre>
<p>This was very easy to solve, but we lost a lot of time in finding the reason why this stupido check box was always checked. And why the hell is this bug still not solved in Symfony ?</p>
<p>In the mean time patch your symfony or create your own checkbox widget <img src='http://www.devexp.eu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<div class="shr-publisher-681"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.devexp.eu/2009/04/23/sfwidgetforminputcheckbox-unchecked-bug/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>A few helpful PHP date methods</title>
		<link>http://www.devexp.eu/2009/04/14/a-few-helpfull-php-date-methods/</link>
		<comments>http://www.devexp.eu/2009/04/14/a-few-helpfull-php-date-methods/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 11:08:28 +0000</pubDate>
		<dc:creator>van Rumste Kenneth</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[methods]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://www.devexp.eu/?p=639</guid>
		<description><![CDATA[For a lot of people dates in PHP are an issue, and the PHP functions aren&#8217;t sufficient enough to do all converts you need. Therefore you find a few easy PHP date conversion methods. Feel free to add your own &#8230; <a href="http://www.devexp.eu/2009/04/14/a-few-helpfull-php-date-methods/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>For a lot of people dates in PHP are an issue, and the PHP functions aren&#8217;t sufficient enough to do all converts you need.<br />
Therefore you find a few easy PHP date conversion methods. Feel free to add your own methods or requests in the comments as we know that these methods don&#8217;t cover everything. You can see it for yourself when you read the rest of this entry:</p>
<ul>
<li>get start and end date for the next two months in an array</li>
<li>get the datetime for a specific user culture in Symfony</li>
<li>get all days between a given start and end date and return it in an array</li>
<li>get the difference between two dates</li>
</ul>
<p><span id="more-639"></span></p>
<ol>
<li><strong>get start and end date for the next two months in an array </strong><span style="text-decoration: underline;"><br />
input</span>: nothing<br />
<span style="text-decoration: underline;">output</span>:<br />
array[0] = 1239706452<br />
array[1] = 1244976852<br />
<span style="color: #339966;">*updated -&gt; thx naholyr</span>
<pre class="brush: php; title: ; notranslate">
/**
 * get the next two months starting from today.
 *
 * @return array
 */
 public function getNextTwoMonths(){
 return array(time(), strtotime(’+2 month’));
 }
</pre>
</li>
<li><strong>get the datetime for a specific user culture in Symfony</strong><span style="text-decoration: underline;"><br />
input</span>: 16/09/08 <span style="text-decoration: underline;"><br />
output</span>: 2008-09-16 23:35:55
<pre class="brush: php; title: ; notranslate">
 /**
 * Parses a date String from a specific culture to a Date.
 *
 * input example: 16/09/08
 *
 * returns: DateTime (Date)
 * @param String $period
 * @return Array of DateTime objects
 */
 public function parseDate($period) {

 $userCulture =  sfContext::getInstance()-&gt;getUser()-&gt;getCulture();

 $timestamp = sfContext::getInstance()-&gt;getI18N()-&gt;getTimestampForCulture($period, $userCulture);

 $period = new DateTime(date('Y-m-d H:i:s', $timestamp));

 return $period;
 }
</pre>
</li>
<li><strong>get all days between a given start and end date and return it in an array.</strong><span style="text-decoration: underline;"><br />
input</span>: 2 DateTime dates<span style="text-decoration: underline;"><br />
output</span>: array of days<br />
day[0] = 2008-12-10<br />
day[1] = 2008-12-11
<pre class="brush: php; title: ; notranslate">
/**
 * With a given start and end date it will creates all the dates in between and return
 * it in an array.
 *
 * @param DateTime $startDate
 * @param DateTime $endDate
 * @return Array
 */
 public function getDaysByPeriod(DateTime $startDate, DateTime $endDate) {

 $startDt = clone $startDate;

 $days = array();

 while ( $startDt-&gt;format('U') &lt;= $endDt-&gt;format('U') ) {
 $days[] = $startDt-&gt;format('Y-m-d');
 $startDt-&gt;modify(&quot;+1 days&quot;);
 }

 return $days;
 }
</pre>
</li>
<li><strong>get the difference between two dates</strong><span style="text-decoration: underline;"><br />
input</span>: <span style="text-decoration: underline;"><br />
</span>2009-04-14 10:08:35<br />
2009-04-15 10:10:35<br />
<span style="text-decoration: underline;"> output</span>: unix timestamp of the difference<br />
<span style="color: #339966;">* updated -&gt; thx Toni and David</span>
<pre class="brush: php; title: ; notranslate">
/**
 * get the difference between two dates
 *
 * @param date $firstTime
 * @param date $lastTime
 * @return integer
 */
public function timeDiff($firstTime,$lastTime)
{
 return strtotime($lastTime) - strtotime($firstTime);
}
</pre>
</li>
</ol>
<div class="shr-publisher-639"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.devexp.eu/2009/04/14/a-few-helpfull-php-date-methods/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>PHP DOMDocument: Convert Array to Xml</title>
		<link>http://www.devexp.eu/2009/04/11/php-domdocument-convert-array-to-xml/</link>
		<comments>http://www.devexp.eu/2009/04/11/php-domdocument-convert-array-to-xml/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 08:56:42 +0000</pubDate>
		<dc:creator>Van de Voorde Toni</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[DOMDocument]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.devexp.eu/?p=605</guid>
		<description><![CDATA[Recently I start working on an export module to invoice applications. One of them uses a very simple xml structure (simple nodes without attributes etc.) and therefore I wanted to create this xml also in a very simple way: from &#8230; <a href="http://www.devexp.eu/2009/04/11/php-domdocument-convert-array-to-xml/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><img src="http://www.devexp.eu/wp-content/uploads/2009/04/elephant-elephant-php-logo1.png" alt="php" title="php" width="146" height="110" class="alignright size-full wp-image-611" />Recently I start working on an export module to invoice applications. One of them uses a very simple xml structure (simple nodes without attributes etc.) and therefore I wanted to create this xml also in a very simple way: from an array.</p>
<p>I decided the use DOM, and not e.g. SimpleXML, because I need to validate my xml with a schema.</p>
<p>After a quick search on the internet I found several snippets that could do the trick until I had to set the same element tag name on the same level:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;nodes&gt;
	&lt;node&gt;text&lt;/node&gt;
	&lt;node&gt;text&lt;/node&gt;
&lt;/nodes&gt;
</pre>
<p>The snippets I found use the index of an array to create the name of the element and the value for the text part. Only everyone knows that you cannot set 2 keys with the same name in an array. </p>
<p>So what could we do to improve this ?</p>
<p><span id="more-605"></span><br />
I changed a snippet so it can generate the example above. The array should now look like this:</p>
<pre class="brush: php; title: ; notranslate">
array (
	“nodes” =&gt; array (
		“node” =&gt; array (
			0 =&gt; “text”
			1 =&gt; “text”
		)
	)
)
</pre>
<p>Since you cannot set integers as element tags, it checks if the index is an integer and if it is it loops the array to recreate the same element tag name with the new value.</p>
<p>I added the function in a class which extends the DOMDocument class (<a href='http://www.devexp.eu/wp-content/uploads/2009/04/xmldomconstructclassphp.gz'>XmlDomConstruct</a>):</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/**
 * Extends the DOMDocument to implement personal (utility) methods.
 *
 * @author Toni Van de Voorde
 */
class XmlDomConstruct extends DOMDocument {

	/**
	 * Constructs elements and texts from an array or string.
	 * The array can contain an element's name in the index part
	 * and an element's text in the value part.
	 *
	 * It can also creates an xml with the same element tagName on the same
	 * level.
	 *
	 * ex:
	 * &lt;nodes&gt;
	 *   &lt;node&gt;text&lt;/node&gt;
	 *   &lt;node&gt;
	 *     &lt;field&gt;hello&lt;/field&gt;
	 *     &lt;field&gt;world&lt;/field&gt;
	 *   &lt;/node&gt;
	 * &lt;/nodes&gt;
	 *
	 * Array should then look like:
	 *
	 * Array (
	 *   &quot;nodes&quot; =&gt; Array (
	 *     &quot;node&quot; =&gt; Array (
	 *       0 =&gt; &quot;text&quot;
	 *       1 =&gt; Array (
	 *         &quot;field&quot; =&gt; Array (
	 *           0 =&gt; &quot;hello&quot;
	 *           1 =&gt; &quot;world&quot;
	 *         )
	 *       )
	 *     )
	 *   )
	 * )
	 *
	 * @param mixed $mixed An array or string.
	 *
	 * @param DOMElement[optional] $domElement Then element
	 * from where the array will be construct to.
	 *
	 */
	public function fromMixed($mixed, DOMElement $domElement = null) {

		$domElement = is_null($domElement) ? $this : $domElement;

		if (is_array($mixed)) {
			foreach( $mixed as $index =&gt; $mixedElement ) {

				if ( is_int($index) ) {
					if ( $index == 0 ) {
						$node = $domElement;
					} else {
						$node = $this-&gt;createElement($domElement-&gt;tagName);
						$domElement-&gt;parentNode-&gt;appendChild($node);
					}
				} 

				else {
					$node = $this-&gt;createElement($index);
					$domElement-&gt;appendChild($node);
				}

				$this-&gt;fromMixed($mixedElement, $node);

			}
		} else {
			$domElement-&gt;appendChild($this-&gt;createTextNode($mixed));
		}

	}

}
?&gt;
</pre>
<p>And here is a very simple example on how you can use this class:</p>
<pre class="brush: php; title: ; notranslate">
$array = array(
  &quot;nodes&quot; =&gt; array(
    &quot;node&quot; =&gt; array(
      0 =&gt; &quot;text&quot;,
      1 =&gt; &quot;text&quot;
)));

$this-&gt;dom = new XmlDomConstruct('1.0', 'utf-8');
$this-&gt;dom-&gt;fromMixed($array);

echo $this-&gt;dom-&gt;saveXML();
</pre>
<p>Isn&#8217;t that wonderful? You don&#8217;t even have to know how to construct xmls with the DOMDocument object. Of course this will only work for simple xmls.</p>
<p>Maybe, if I have the time, I’ll try to add the possibility to insert attributes to elements.</p>
<div class="shr-publisher-605"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.devexp.eu/2009/04/11/php-domdocument-convert-array-to-xml/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

