<?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>rootelement, inc. &#187; framework</title>
	<atom:link href="http://www.rootelement.net/tag/framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rootelement.net</link>
	<description>Invest in your business.</description>
	<lastBuildDate>Mon, 21 Feb 2011 20:56:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ants in my Zend Framework (with doctrine for good measure)</title>
		<link>http://www.rootelement.net/2009/07/ants-in-my-zend-framework-with-doctrine-for-good-measure/</link>
		<comments>http://www.rootelement.net/2009/07/ants-in-my-zend-framework-with-doctrine-for-good-measure/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 12:08:22 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://sproif.com/?p=137</guid>
		<description><![CDATA[A few simple steps will free you from running your doctrine tasks from the command line.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m starting to use <a title="Zend Framework Home" href="http://zendframework.com/" target="_blank">Zend Framework 1.8.4</a> with <a title="Doctrine Object Relational Mapper Home" href="http://www.doctrine-project.org/">Doctrine Object Relational Mapper</a> (because after working on a java/<a title="Hibernate Homepage" href="https://www.hibernate.org/" target="_blank">hibernate</a> project, I can&#8217;t go back to writing SQL and building databases)  With Doctrine ORM, you can define a <a title="Example of a Doctrine data model in YAML" href="http://www.doctrine-project.org/documentation/manual/1_0/en/yaml-schema-files">data model in  YAML</a> or XML and it will build the database with foreign keys, etc, etc ,etc&#8230; learn more on that here.<br />
<span id="more-151"></span><br />
On starting my project, I looked around to see what everyone else was doing.  Since 1.8.4 is relatively new, and there were some pretty neat changes, there aren&#8217;t many good tutorials out there.</p>
<p>That being said, and because of said java/hibernate project I&#8217;ve been working on, I&#8217;ve become quite familiar with <a title="Apache Ant Home" href="http://ant.apache.org/">Apache Ant</a>.  It&#8217;s basically an easy way to do some of the mundane work and sometimes heavy lifting in day to day programming.  That, and I use <a title="Eclipse Development Environment" href="http://www.eclipse.org/">Eclipse IDE</a>, so wasn&#8217;t too fond of always running to the command prompt to rebuild my models, create a zend module, etc.</p>
<p>So here&#8217;s what I&#8217;ve come up with.</p>
<p>I started with this tutorial: <a title="Tutorial on setting up a doctrine/zend project." href="http://www.danceric.net/2009/06/06/doctrine-orm-and-zend-framework/" target="_blank">Doctrine ORM and Zend Framework</a> It shows you how to create a Zend 1.8.4 project with doctrine.  The key aspect is the doctrine-cli.php script.</p>
<p>I should let you know, while I do use Eclipse for most of my projects, a while back I bought <a title="Zend Studio Homepage" href="http://www.zend.com/products/studio/" target="_blank">Zend Studio for Eclipse</a>. I think it&#8217;s much better for writing PHP than any plugin for eclipse (<a title="PDT PHP Eclipse Plugin" href="http://www.eclipse.org/pdt/">PDT</a>, <a title="PHP Eclipse Plugin" href="http://www.phpeclipse.com/">PHPEclipse</a>).  If you write a lot of PHP, ZS4E is very very worth the money.  While it does say it is &#8220;zend studio <strong>for</strong> eclipse&#8221;, it installs its own installation of eclipse.  If you find yourself in this boat, and want to use Ant in Zend Studio for Eclipse, check out <a title="Enabling Apache Ant in Zend Studio for Eclipse" href="http://damagestudios.net/blog/2009/01/12/ant-and-zend-studio" target="_blank">this tutorial</a>.  It&#8217;s rather screwy that you can&#8217;t install ant tools easily, but this definitely does the trick.</p>
<p>But I digress&#8230; let&#8217;s get started.</p>
<p>Here is the directory structure of my project, basically defined by the above tutorial:</p>
<pre class="brush: plain;">- root
-  htdocs [zend framework project root]
    - application
        - [all application folders]
        - doctrine
    - library
    - public
    - scripts
    - test
-  .project
-  build.xml
-  env.properties</pre>
<p>The body of env.properties looks like this:</p>
<pre class="brush: plain;">zf.project.basedir=htdocs
doctrine.scripts.path=${zf.project.basedir}/scripts</pre>
<p>And the body of the build.xml looks like this:</p>
<pre class="brush: xml;">&lt;project name=&quot;zf-doctrine-project&quot;&gt;
     &lt;property file=&quot;env.properties&quot; /&gt;
     &lt;target name=&quot;doctrine.cli&quot; description=&quot;Run a doctrine task on doctrine-cli.php - default reload&quot;&gt;
          &lt;input message=&quot;Enter a task:&quot;
               addproperty=&quot;doctrine.task&quot;
               defaultvalue=&quot;build-all-reload&quot; /&gt;
          &lt;fail unless=&quot;doctrine.task&quot; message=&quot;No task selected&quot; /&gt;
          &lt;exec dir=&quot;${doctrine.scripts.path}&quot;
               command=&quot;php doctrine-cli.php ${doctrine.task} y&quot;/&gt;
     &lt;/target&gt;
&lt;/project&gt;</pre>
<p>Although it&#8217;s painfully self-explanatory, for the sake of completeness, here&#8217;s what it does, line by line:</p>
<p>2.  Loads in the env.properties file<br />
3.  Defines the target, which is like a job/task in ant<br />
4. &#8211; 6.  Prompts the user to enter a task to pass to the cli script (just like you would pass in the command line)<br />
7.  Makes sure the user enters a value<br />
8. &#8211; 9. Executes the php script, passing in the entered task as a command line option, and forces yes to &#8220;are you sure?&#8221;</p>
<p>Now, the fun part.</p>
<p>In your project in Eclipse, open the ant window by going to Window &gt; Show View &gt; Other and select Ant under the Ant folder.  When you see the Ant View, either open your ant file in that window using it&#8217;s open dialog, or just drag your build.xml to that panel.  You&#8217;ll see the little white file with the ant on it and whatever you have as the name attribute of the &lt;project&gt; tag in your build xml.  Expand that so you can see the targets, and you should see this:</p>
<div id="attachment_138" class="wp-caption aligncenter" style="width: 285px"><img class="size-full wp-image-138 " title="Eclipse Ant View" src="http://www.rootelement.net/wp-content/uploads/2009/07/eclipseantview.jpg" alt="Showing the doctrine task in the eclipse ant view" width="275" height="190" /><p class="wp-caption-text">Showing the doctrine task in the eclipse ant view</p></div>
<p>Now if you double click that target, you should see a prompt for the task you want to run.  The default value there will run your schema.yml and rebuild your db and models.</p>
<p>Crafty kids may notice that i have the &#8220;Hide internal targets button&#8221; turned on in that image&#8230; well, those targets are for another show&#8230;  (damn you crafty kids&#8230;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rootelement.net/2009/07/ants-in-my-zend-framework-with-doctrine-for-good-measure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

