<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://mirmodynamics.com/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Mirmo Dynamics - Coding</title>
  <link>http://mirmodynamics.com/</link>
  <atom:link href="http://mirmodynamics.com/feed/category/Coding/rss2" rel="self" type="application/rss+xml"/>
  <description>Si tu kiffes pas reunoi, t'écoutes pas et puis c'est tout.</description>
  <language>en</language>
  <pubDate>Sun, 14 Mar 2010 19:59:01 +0100</pubDate>
  <copyright>2003-2009 &amp;copy; Geoffrey Bachelet</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>having fun with vim, an event tracker</title>
    <link>http://mirmodynamics.com/post/2009/03/08/having-fun-with-vim%2C-an-event-tracker</link>
    <guid isPermaLink="false">urn:md5:dd9c2194c796331acd7a9a403f01f67e</guid>
    <pubDate>Sun, 08 Mar 2009 21:16:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>timetracking</category><category>vim</category><category>vimscript</category>    
    <description>    &lt;p&gt;The idea of this script came by realizing that the main reason I (almost) never fill my timesheet, is because I just forget it. How easier could it be if my editor (namely vim) could fill it for me ? Or at least, help me fill it. This script is meant to help this process. It will hook to every configured event (in the code below, &lt;code&gt;BufRead&lt;/code&gt; and &lt;code&gt;BufNewFile&lt;/code&gt;) and add a log line to the log file. Easy heh ? Of course, the script it self won't be of much use, I'll have to add some more events to track as well as writting some kind of frontend for it, with reporting &amp;amp; all.&lt;/p&gt;

&lt;pre&gt;
if exists('trackloaded')
  finish
endif

&amp;quot; list of autocmd events:
&amp;quot; http://www.vim.org/htmldoc/autocmd.html#autocmd-events
let trackevents = ['BufRead', 'BufNewFile', 'BufEnter', 'BufWrite', 'BufLeave']
let trackfile   = '/tmp/timetrack.dat'
let trackloaded = 1

for event in trackevents
  execute 'autocmd '.event.' * call Track(&amp;quot;'.event.'&amp;quot;)'
endfor

unlet event

function Track(event)
  let l:filename = @%
  if l:filename != g:trackfile
    if match(l:filename, '/') != 0
      let l:filename = getcwd().'/'.l:filename
    endif
    silent execute '!echo `date +\%s` '.a:event.' '.l:filename.' &amp;gt;&amp;gt; '.g:trackfile
  endif
endfunction
&lt;/pre&gt;


&lt;p&gt;You might note from this snippet that I'm not very comfortable with vimscripting :-) If you have a better way of doing this (I'm thinking mostly about the file writting here), don't hesitate to tell me.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2009/03/08/having-fun-with-vim%2C-an-event-tracker#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2009/03/08/having-fun-with-vim%2C-an-event-tracker#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1180</wfw:commentRss>
      </item>
    
  <item>
    <title>Replacing short tags with proper PHP tags</title>
    <link>http://mirmodynamics.com/post/2009/01/29/Replacing-short-tags-with-proper-PHP-tags</link>
    <guid isPermaLink="false">urn:md5:d6481ef46111e084484a9fa1c9c30d82</guid>
    <pubDate>Thu, 29 Jan 2009 10:37:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>pcre</category><category>php</category><category>regexp</category><category>short_tags</category>    
    <description>    &lt;p&gt;This is a little script I made to get rid of those damned short tags.&lt;/p&gt;

&lt;pre&gt;
[php]
&amp;lt;?php

while ($file = trim(fgets(STDIN)))
{
  $content = file_get_contents($file);

  $search  = array('/&amp;lt;\?=/', '/&amp;lt;\?(?!php|xml)/');
  $replace = array('&amp;lt;?php echo ', '&amp;lt;?php ');

  if ($content != ($new_content = preg_replace($search, $replace, $content)))
  {
    file_put_contents($file, $new_content);
  }
}
&lt;/pre&gt;


&lt;p&gt;Just put this in a file, &lt;code&gt;short_tags.php&lt;/code&gt; for example, and run something like:&lt;/p&gt;

&lt;pre&gt;
$ find . -name &amp;quot;*.php&amp;quot; | php ./short_tags.php
&lt;/pre&gt;


&lt;p&gt;I would have done it with &lt;code&gt;sed&lt;/code&gt;, but it doesn't seem to support &lt;acronym&gt;PCRE&lt;/acronym&gt;, and I don't know how to do negative lookahead (the &lt;code&gt;(?!php|xml)&lt;/code&gt; thingy) with POSIX based regexp (if it's even supported) :/&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: Actually, POSIX Regexps DO support negative lookahead (as well as positive lookahead and lookbehind) with the same syntax as PCRE regexps. But grep doesn't use POSIX regexps, it uses things called &lt;acronym title=&quot;Basic RegExps&quot;&gt;BRE&lt;/acronym&gt; and &lt;acronym title=&quot;Extended RegExps&quot;&gt;ERE&lt;/acronym&gt; that I've never heard of before. Too bad.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2009/01/29/Replacing-short-tags-with-proper-PHP-tags#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2009/01/29/Replacing-short-tags-with-proper-PHP-tags#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1174</wfw:commentRss>
      </item>
    
  <item>
    <title>Why I switched from ZF</title>
    <link>http://mirmodynamics.com/post/2008/11/24/Why-I-switched-from-ZF</link>
    <guid isPermaLink="false">urn:md5:d381f16f37fb19ec4c72aae647d87107</guid>
    <pubDate>Mon, 24 Nov 2008 23:50:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>framework</category><category>reasons</category><category>switch</category><category>zend framework</category>    
    <description>    &lt;p&gt;Please note all the reasons I'm about to give are the reason I had at the time I quited ZF, that's like 6 months ago or so, so be aware that things may have evolved, and since &lt;strong&gt;this is not a rant&lt;/strong&gt;, I won't even check if they actually changed (as I really don't give a damn). Also, I'm writing this post only because I said I'd write it, I'm not trying to convince anyone, nor am I trying to start a discussion about the pros and cons of ZF.&lt;/p&gt;


&lt;p&gt;First, I think the Zend Framework is a bit complex. That's quite vague for a framework of that size, but let me explain. There are a lot of things to know and do before you can even think of really working on your project. Zend Framework has a lot of classes, and you better know a lot of them to get productive.&lt;/p&gt;


&lt;p&gt;Which lead to another problem: configuration over convention. This concept is deeply rooted inside the framework, and I think it's just wrong (although I know it's a pro for some people). It forces you to know instead of just being able to guess (and I think knowing &lt;em&gt;how to guess&lt;/em&gt; is very important for a developer), so you just can't install the framework and start working ootb, you have to read docs (well, you always have to read docs, but), you have to read A WHOLE FUCKIN LOTS OF DOCS, and god, it's boring and greatly time-consuming.&lt;/p&gt;


&lt;p&gt;Time-consuming, because the documentation is poorly structured. I've always found it hard to find exactly what you need in the documentation. Not sure why (and that's not a point I will expand on, since this is very subjective, and most of other frameworks have equally poorly structured doc).&lt;/p&gt;


&lt;p&gt;Now my main point: Zend Framework is nothing more than a Zend sponsored PEAR. You have no tools to ease or speed application development, no coupling between components (yet again, I know this is a pro for some people ;), no code generation, no easy database management, no task handling, etc, etc. So what's the point using a framework if he doesn't really help you developing ? Not much if you ask me (and if you're reading this, we could assume you asked).&lt;/p&gt;


&lt;p&gt;Add to all this poorly written components (some of them don't even follow the coding standard !), stupid decisions (i18n exceptions anyone ?) and marketing-drived release policy, and there you are, one less Zend Framework enthusiast (not that it matters anyway).&lt;/p&gt;


&lt;p&gt;So thinking about all that, there's a single word that describe exactly why I've been disappointed by ZF: &lt;strong&gt;expectation&lt;/strong&gt;. Zend Framework is just not meeting my expectations, it doesn't fit my needs, that's why I switched to another framework, that, for now, I'm fully satisfied with.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/11/24/Why-I-switched-from-ZF#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/11/24/Why-I-switched-from-ZF#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1158</wfw:commentRss>
      </item>
    
  <item>
    <title>About the self keyword in static methods</title>
    <link>http://mirmodynamics.com/post/2008/07/14/About-the-self-keyword-in-static-methods</link>
    <guid isPermaLink="false">urn:md5:610999c6e714c4d650b1d2ea45ffc0b3</guid>
    <pubDate>Mon, 14 Jul 2008 16:04:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>callback</category><category>nonsense</category><category>php</category><category>self</category><category>static</category><category>weird</category>    
    <description>    &lt;p&gt;While setting up a test server for some software I wrote at the office, I eventually noticed the following notice:&lt;/p&gt;

&lt;pre&gt;
Notice: Use of undefined constant self - assumed 'self'
&lt;/pre&gt;


&lt;p&gt;That surprised me, because 1) I though self were some kind of &amp;quot;superglobal&amp;quot; constant or a special token of the parser, always automatically available in a static method and 2) the code works. So what's up in there ? Let's make a simple test:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php

class foo {
	static public function bar() {
		var_dump(is_callable(array('self', 'foobar')));
		var_dump(is_callable(array(self, 'foobar')));

		var_dump(class_exists('self'));
		var_dump(class_exists(self));

		self::foobar();
	}

	static public function foobar() {
	}
}

foo::bar();

&lt;/pre&gt;


&lt;p&gt;Executing the above code will yeld the following result:&lt;/p&gt;

&lt;pre&gt;
bool(true)

Notice: Use of undefined constant self - assumed 'self' in /home/geoffreyb/test.php on line 6
bool(true)
bool(false)

Notice: Use of undefined constant self - assumed 'self' in /home/geoffreyb/test.php on line 9
bool(false)
&lt;/pre&gt;


&lt;p&gt;What do we learn here ? Not much actually. It seems like &lt;code&gt;self&lt;/code&gt; as a constant is only available when used with the scope resolution operator, aka double-colon or paamayim nekudotayim. When you want to use it in, for example, a callback definition, use a string representation of self:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php

is_callable(array('self', 'bar'));
call_user_func(array('self', 'bar'));
&lt;/pre&gt;


&lt;p&gt;Which, while making absolutely no sense at all, works. Another way to get around this is to use the &lt;code&gt;get_class()&lt;/code&gt; function that, without any argument, will return the name of the class you're currently in (&lt;code&gt;foo&lt;/code&gt; in my example).&lt;/p&gt;


&lt;p&gt;After a bit more investiging, I found out that there is nothing special about the &lt;em&gt;self&lt;/em&gt; token, which is actually a string token. You can check this very easily with the following code:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php

class foo {
	static public function bar() {
		self::foobar();
	}
}

var_dump(token_get_all(file_get_contents(__FILE__)));
&lt;/pre&gt;


&lt;p&gt;Somewhere inside the output, you'll find the following piece of text:&lt;/p&gt;

&lt;pre&gt;
  array(2) {
    [0]=&amp;gt;
    int(307)
    [1]=&amp;gt;
    string(4) &amp;quot;self&amp;quot;
  }
&lt;/pre&gt;


&lt;p&gt;And the token id &lt;code&gt;307&lt;/code&gt; is resolved by &lt;code&gt;token_name&lt;/code&gt; to &lt;code&gt;string&lt;/code&gt;.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/07/14/About-the-self-keyword-in-static-methods#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/07/14/About-the-self-keyword-in-static-methods#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1112</wfw:commentRss>
      </item>
    
  <item>
    <title>Zend Framework 1.5.1 PEAR package is available</title>
    <link>http://mirmodynamics.com/post/2008/03/31/Zend-Framework-151-PEAR-package-is-available</link>
    <guid isPermaLink="false">urn:md5:4d8dcb3deedffc0ab3eb1d830c186f45</guid>
    <pubDate>Mon, 31 Mar 2008 17:08:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>package</category><category>pear</category><category>phpmafia</category><category>zend framework</category>    
    <description>    &lt;p&gt;A little late sorry, but ZF 1.5.1's package is now ready.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/03/31/Zend-Framework-151-PEAR-package-is-available#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/03/31/Zend-Framework-151-PEAR-package-is-available#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1093</wfw:commentRss>
      </item>
    
  <item>
    <title>ruby: url_to_constant</title>
    <link>http://mirmodynamics.com/post/2008/03/27/ruby%3A-url_to_constant</link>
    <guid isPermaLink="false">urn:md5:5bc21c2e576e73435e4b1e0c555fffe1</guid>
    <pubDate>Thu, 27 Mar 2008 23:04:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>constant</category><category>ruby</category><category>url</category><category>useless</category>    
    <description>    &lt;p&gt;A small bit of ruby to get a constant from an &lt;acronym&gt;URL&lt;/acronym&gt;:&lt;/p&gt;

&lt;pre&gt;
[ruby]
require 'uri'
def url_to_constant(url)
	return URI.parse(url).host.gsub(/^www\./, '').capitalize.gsub(/[^a-z][a-z]/i) { |m| m.gsub(/[^a-z]/, '').upcase }.constantize
end
&lt;/pre&gt;


&lt;p&gt;Nothing exceptionnal here, just a pretext to post something.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/03/27/ruby%3A-url_to_constant#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/03/27/ruby%3A-url_to_constant#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1091</wfw:commentRss>
      </item>
    
  <item>
    <title>Zend Framework 1.5 PEAR package is available</title>
    <link>http://mirmodynamics.com/post/2008/03/22/Zend-Framework-15-PEAR-package-is-available</link>
    <guid isPermaLink="false">urn:md5:f6deb9b27f134853c91f21d4c952614f</guid>
    <pubDate>Sat, 22 Mar 2008 18:19:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>1.5</category><category>package</category><category>pear</category><category>phpmafia</category><category>zend framework</category>    
    <description>    &lt;p&gt;The long awaited 1.5 version of the &lt;a href=&quot;http://framework.zend.com/&quot;&gt;Zend Framework&lt;/a&gt; has landed for some days already, and here comes its pear package. Please note the api version changed to 1.5 in this package.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/03/22/Zend-Framework-15-PEAR-package-is-available#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/03/22/Zend-Framework-15-PEAR-package-is-available#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1090</wfw:commentRss>
      </item>
    
  <item>
    <title>Plugin &quot;related by tags&quot; pour dotclear 2, deuxième</title>
    <link>http://mirmodynamics.com/post/2008/03/10/Plugin-related-by-tags-pour-dotclear-2-deuxieme</link>
    <guid isPermaLink="false">urn:md5:5e7f17894657fe0198135403c49f72f8</guid>
    <pubDate>Mon, 10 Mar 2008 21:48:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>dotclear2</category><category>plugin</category><category>related by tags</category>    
    <description>    &lt;p&gt;Après de longs mois d'attente, le &lt;em&gt;related by tags&lt;/em&gt; nouveau arrive enfin ! Au menu des réjouissances, une interface de configuration, ainsi qu'un widget font leur apparition. Vous disposez donc désormais de deux manières d'afficher les billets liés, directement en modifiant le template comme avant:&lt;/p&gt;

&lt;pre&gt;
{{tpl:include src=&amp;quot;_related_by_tags.html&amp;quot;}}
&lt;/pre&gt;


&lt;p&gt;ou tout simplement en activant le widget correspondant, que vous pouvez configurer comme vous l'entendez. Bien sur, ce widget ne s'affichera que lors de la visualisation d'un billet.&lt;/p&gt;


&lt;p&gt;Au chapitre des fonctionnalités / bugfix manquant(e)s, on notera le bug lié à l'utilisation de postgresql, ainsi que la traduction française, qui sera pour plus tard.&lt;/p&gt;


&lt;p&gt;Encore une fois, n'hésitez pas à poster tous vos commentaires ici même.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/03/10/Plugin-related-by-tags-pour-dotclear-2-deuxieme#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/03/10/Plugin-related-by-tags-pour-dotclear-2-deuxieme#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1087</wfw:commentRss>
      </item>
    
  <item>
    <title>Zend Framework 1.0.4 PEAR package is available</title>
    <link>http://mirmodynamics.com/post/2008/02/27/Zend-Framework-104-PEAR-package-is-available</link>
    <guid isPermaLink="false">urn:md5:86aeb0f2eaf2c2f7b63fcc1f234ad94d</guid>
    <pubDate>Wed, 27 Feb 2008 11:17:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>package</category><category>pear</category><category>phpmafia</category><category>zend framework</category>    
    <description>    &lt;p&gt;The package for the last 1.0.x release, 1.0.4, is now available on the phpmafia pear channel. Please report any issue in the comment of this post. The Zend_Locale's xml bug should now be fixed (they are now considered as php and thus put at the &lt;em&gt;right&lt;/em&gt; place, which is not the best way to fix the bug I guess but at least it should work for now).&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/02/27/Zend-Framework-104-PEAR-package-is-available#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/02/27/Zend-Framework-104-PEAR-package-is-available#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1085</wfw:commentRss>
      </item>
    
  <item>
    <title>yaml, activerecord and acts_as_nested_set</title>
    <link>http://mirmodynamics.com/post/2007/12/02/yaml-activerecord-and-acts_as_nested_set</link>
    <guid isPermaLink="false">urn:md5:8723be74d366c359a8c02a308d5844be</guid>
    <pubDate>Sun, 02 Dec 2007 16:41:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>activerecord</category><category>rails</category><category>rake</category><category>ruby</category><category>yaml</category>    
    <description>    &lt;p&gt;I used to use this &lt;a href=&quot;http://thecaribbeanweblog.com/index.php/2007/06/21/150-yaml-et-activerecord-et-sql-plus-generalement&quot;&gt;yaml_to_ar lib&lt;/a&gt; from &lt;a href=&quot;http://thecaribbeanweblog.com/&quot;&gt;christophe&lt;/a&gt; to load categories tree into my database, using &lt;code&gt;&lt;a href=&quot;http://wiki.rubyonrails.org/rails/pages/ActsAsTree&quot;&gt;acts_as_tree&lt;/a&gt;&lt;/code&gt; in the model that was perfect. Arrived the time when I felt the need to use &lt;code&gt;&lt;a href=&quot;http://api.rubyonrails.com/classes/ActiveRecord/Acts/NestedSet/ClassMethods.html&quot;&gt;acts_as_nested_set&lt;/a&gt;&lt;/code&gt; instead, for which I had to fill the &lt;code&gt;lft&lt;/code&gt; and &lt;code&gt;rgt&lt;/code&gt; columns. So I just rewrote the &lt;em&gt;yaml_to_ar&lt;/em&gt; piece of code (put this in &lt;code&gt;lib/yaml_to_ar.rb&lt;/code&gt;):&lt;/p&gt;

&lt;pre&gt;
[ruby]
require 'yaml'

class YAML_to_AR

  def initialize(file, model)
    @data = File.open(file) { |yf| YAML::load( yf ) }
    @model = model
  end

  def process(data = @data, parent = nil)
    if data.is_a? Array
      data.each do |val|
        process(val, parent)
      end
    elsif data.is_a? Hash
      data.each do |key,val|
        parent = @model.create(:title =&amp;gt; key)
        process(val, parent)
      end
    elsif data.is_a? String
      parent.add_child(@model.create(:title =&amp;gt; data))
    end
  end

 end
&lt;/pre&gt;


&lt;p&gt;This should handle both &lt;code&gt;acts_as_tree&lt;/code&gt; and &lt;code&gt;acts_as_nested&lt;/code&gt;. To ease things a bit further, I also wrote a rake task (to drop in &lt;code&gt;lib/tasks/db_load_categories.rake&lt;/code&gt; for example):&lt;/p&gt;

&lt;pre&gt;
[ruby]
namespace :db do
  desc &amp;quot;Loads categories defaults data&amp;quot;
  task :load_categories =&amp;gt; :environment do
    require 'lib/yaml_to_ar'
    Category.delete_all
    categories = YAML_to_AR.new('db/categories.yml', Category)
    categories.process
  end
end
&lt;/pre&gt;


&lt;p&gt;Now I just &lt;code&gt;rake db:load_categories&lt;/code&gt;, and voila !&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/12/02/yaml-activerecord-and-acts_as_nested_set#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/12/02/yaml-activerecord-and-acts_as_nested_set#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1077</wfw:commentRss>
      </item>
    
  <item>
    <title>my first rails plugin: named_resources</title>
    <link>http://mirmodynamics.com/post/2007/11/28/my-first-rails-plugin%3A-named_resources</link>
    <guid isPermaLink="false">urn:md5:28c1356e1cfe998c3393fe046bb94dcb</guid>
    <pubDate>Wed, 28 Nov 2007 13:00:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>plugin</category><category>rails</category><category>resources</category><category>ruby</category>    
    <description>    &lt;p&gt;It's a simple plugin (2 lines of code beside class and modules declarations) which allows routes created via the &lt;code&gt;map.resources&lt;/code&gt; mechanism to be customized. Say you have the following map:&lt;/p&gt;

&lt;pre&gt;
[ruby]
map.resources :members
&lt;/pre&gt;


&lt;p&gt;It will generate routes like:&lt;/p&gt;

&lt;pre&gt;
/members
/members/:id
/members/new
&lt;/pre&gt;


&lt;p&gt;No say you want to i18n your app, in french for example, what do you do ? You just can't out of the box. This is where my plugin enters into action, just add a &lt;code&gt;:route_name&lt;/code&gt; parameter to the &lt;code&gt;map.resources&lt;/code&gt; call and you're set:&lt;/p&gt;

&lt;pre&gt;
[ruby]
map.resources :members, :route_name =&amp;gt; 'utilisateurs'
&lt;/pre&gt;


&lt;p&gt;will generate routes like:&lt;/p&gt;
&lt;pre&gt;
/utilisateurs
/utilisateurs/:id
/utilisateurs/new
&lt;/pre&gt;


&lt;p&gt;It shall also work for nested resources, although I did not test that.&lt;/p&gt;


&lt;p&gt;The code is actually pretty simple:&lt;/p&gt;

&lt;pre&gt;
[ruby]
module ActionController
  module Resources
    class Resource
      def path
        route_name = @options.include?(:route_name) ? @options[:route_name] : @plural
        @path ||= &amp;quot;#{path_prefix}/#{route_name}&amp;quot;
      end 
    end 
  end 
end
&lt;/pre&gt;


&lt;p&gt;To install just use &lt;code&gt;script/plugin&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;
script/plugin install http://tools.assembla.com/svn/riskle/rails/plugins/named_resources
&lt;/pre&gt;


&lt;p&gt;or to install as an svn:external resource:&lt;/p&gt;

&lt;pre&gt;
script/plugin install -x http://tools.assembla.com/svn/riskle/rails/plugins/named_resources
&lt;/pre&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/11/28/my-first-rails-plugin%3A-named_resources#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/11/28/my-first-rails-plugin%3A-named_resources#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1076</wfw:commentRss>
      </item>
    
  <item>
    <title>Accessing raw post data in a controller</title>
    <link>http://mirmodynamics.com/post/2007/11/21/Accessing-raw-post-data-in-a-controller</link>
    <guid isPermaLink="false">urn:md5:d8a3050d140c3d8fac1e1de762628c9d</guid>
    <pubDate>Wed, 21 Nov 2007 12:03:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>controller</category><category>http</category><category>post</category><category>raw post data</category><category>zend framework</category>    
    <description>    &lt;p&gt;For some reason, &lt;code&gt;$HTTP_RAW_POST_DATA&lt;/code&gt; does not seem to be set inside an action controller. You'll have to use the &lt;code&gt;php://input&lt;/code&gt; stream wrapper to access raw http post data:&lt;/p&gt;

&lt;pre&gt;
[php]
$raw_post_data = file_get_contents('php://input');
&lt;/pre&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/11/21/Accessing-raw-post-data-in-a-controller#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/11/21/Accessing-raw-post-data-in-a-controller#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1075</wfw:commentRss>
      </item>
    
  <item>
    <title>Extending Zend_Controller_Router_Route: the singleton problem.</title>
    <link>http://mirmodynamics.com/post/2007/11/05/Extending-Zend_Controller_Router_Route%3A-the-singleton-problem</link>
    <guid isPermaLink="false">urn:md5:639fef9d7c01edc0e63ee3f2c2a5c823</guid>
    <pubDate>Mon, 05 Nov 2007 14:37:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>annoying</category><category>dry</category><category>oop</category><category>pattern</category><category>php5</category><category>route</category><category>self</category><category>singleton</category><category>zend framework</category>    
    <description>    &lt;p&gt;Today I ran into an issue while extending &lt;code&gt;Zend_Controller_Router_Route&lt;/code&gt;. I wanted to add a little path pre/post processing in the &lt;code&gt;match()&lt;/code&gt; and &lt;code&gt;assemble()&lt;/code&gt; methods, so I just extended the Route class to add my tiny bits of code into the methods. Except it did not work at all. After a few debuging, it turned out that the Router uses &lt;code&gt;Zend_Controller_Router_Route::getInstance()&lt;/code&gt; to retrieve a route object, which uses a &lt;code&gt;new self();&lt;/code&gt; statement to instantiate the route object. Problem is that &lt;code&gt;self&lt;/code&gt; always refers to the current class definition we're in, if the method is called from a child class, without being overloaded, self will refer to the wrong class.&lt;/p&gt;


&lt;p&gt;Example:&lt;/p&gt;
&lt;pre&gt;
[php]
class Foo {
	public static function getInstance() {
		return new self;
	}
}

class Bar extends Foo {}

var_dump(Bar::getClass());
&lt;/pre&gt;


&lt;p&gt;echoes something like:&lt;/p&gt;

&lt;pre&gt;
object(Foo)#1 (0) {
}
&lt;/pre&gt;


&lt;p&gt;Which is fscking wrong IMHO. A quick workaround is to overload the &lt;code&gt;getInstance&lt;/code&gt; method, which is what I call pretty annoying as it does not follow the DRY principle.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/11/05/Extending-Zend_Controller_Router_Route%3A-the-singleton-problem#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/11/05/Extending-Zend_Controller_Router_Route%3A-the-singleton-problem#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1072</wfw:commentRss>
      </item>
    
  <item>
    <title>How I use the Zend Framework</title>
    <link>http://mirmodynamics.com/post/2007/10/16/How-I-use-the-Zend-Framework</link>
    <guid isPermaLink="false">urn:md5:15540fb9e20bbf5beef4ab8f8c6150ed</guid>
    <pubDate>Mon, 22 Oct 2007 13:39:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>application</category><category>architecture</category><category>conventions</category><category>models</category><category>modules</category><category>php</category><category>zend framework</category>    
    <description>&lt;p&gt;Having started a few applications using the Zend Framework, I came out with a few practices that I tend to use over and over. In this post I'll quickly expose some of them and explain why I do things the way I do them. As you'll notice, most of them are already widely known and used over the &lt;acronym&gt;ZF&lt;/acronym&gt; developer's community. Please remember that these practices are just &lt;em&gt;what I do&lt;/em&gt;, and come with no garanty at all to be &lt;em&gt;best practices&lt;/em&gt;.&lt;/p&gt;    &lt;h3&gt;Directory structure&lt;/h3&gt;


&lt;p&gt;First thing to work out when starting a new Zend Framework powered application, at least if you decide to use the &lt;acronym title=&quot;Zend Framework&quot;&gt;ZF&lt;/acronym&gt;'s &lt;acronym title=&quot;Model View Controller&quot;&gt;MVC&lt;/acronym&gt; component, is the application's directory structure. Here is the one I used, which is a slightly modified version of &lt;a href=&quot;http://framework.zend.com/manual/en/zend.controller.modular.html&quot;&gt;the official recommended structure&lt;/a&gt;. This is essentially a standard modular structure with all directories needed to store various additional data from your application.&lt;/p&gt;

&lt;pre&gt;
application/
	cache/
	config/
		application.ini
		routes.ini
	data/
	layouts/scripts/
	library/App/
	logs/
	modules/
		default/
		user/
document_root/
	css/
	images/
	index.php
	js/
&lt;/pre&gt;


&lt;p&gt;As you can see, I have many directories, each dedicated to a specific file type. This has many advantages, such as always knowing where to find what you're looking for or easily process files of a certain type (think &lt;code&gt;grep foo logs/*&lt;/code&gt;). Also, I name my directories explicitly. I used to call the &lt;code&gt;config&lt;/code&gt; directory &lt;code&gt;etc&lt;/code&gt;, which is the directory holding most configurations files under UNIX systems, but it may not appear that clear to non-UNIX user, while &lt;code&gt;config&lt;/code&gt; is clear enough for everyone.&lt;/p&gt;


&lt;p&gt;Another point you might notice is the that all applications files and data are placed outside the document_root. This is done to avoid unwanted access to such resources. While this is the best way, in my opinion, to do, it may not always be possible (like when you have no control on your actual &lt;code&gt;DocumentRoot&lt;/code&gt;. In this case, you may consider having the following structure:&lt;/p&gt;

&lt;pre&gt;
application/
	cache/
	config/
		application.ini
		routes.ini
	data/
	layouts/scripts/
	library/App/
	logs/
	modules/
		default/
		user/
	tasks/
css/
images/
index.php
js/
&lt;/pre&gt;


&lt;p&gt;Then you can deny any web access to the &lt;code&gt;application/&lt;/code&gt; directory with the following &lt;code&gt;htaccess&lt;/code&gt; rules:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;Directory application&amp;gt;
    Order allow,deny
    Deny from all
&amp;lt;/Directory&amp;gt;
&lt;/pre&gt;


&lt;h3&gt;Did you say modular ?&lt;/h3&gt;


&lt;p&gt;Yeah, I said it actually. Modules in Zend Framework are groups of controllers (along with their corresponding views and models) which sits in their own namespace. One could argue that module's primary goal is to ease code re-use, but I personnaly dunno, as I personnally still have not seen such a use of modules. The drawbacks of re-usable code is that it needs to be abstract enough to fit ant particular situation or so. In this context, I only have a single separate module alongside the default one: the user module. It has Index and Auth controllers, respectively used to perform &lt;acronym title=&quot;Create Read Update Delete&quot;&gt;CRUD&lt;/acronym&gt; and login/logout operations.&lt;/p&gt;


&lt;p&gt;Having re-usable modules implies that all modules containes its own models, or at least, knows where (ie, in which other module) to find its required models. There comes Xend's model loader. This is an action helper which ease the load of models inside controllers, like:&lt;/p&gt;

&lt;pre&gt;
$this-&amp;gt;_helper-&amp;gt;modelLoader(array('MyCoolModel', 'MyOtherModel'));
&lt;/pre&gt;


&lt;p&gt;Easy heh ? The bad point with this helper is that it is restricted to, or at best tricky to use outside, action controllers. That is why I developped my own library loader which I shall present in another blogpost soon.&lt;/p&gt;


&lt;h3&gt;Models naming convention&lt;/h3&gt;


&lt;p&gt;Using the &lt;a href=&quot;http://svn.ralphschindler.com/repo/Xend/&quot;&gt;Xend&lt;/a&gt;'s model loader trained me to adopt what I consider a good model naming convention, basically, it just follows the controller's conventions, that is, prefix the model name with the module's name, so that for example my user model is named like &lt;code&gt;User_Users&lt;/code&gt; (the first &lt;code&gt;User&lt;/code&gt; is the module name, the second &lt;code&gt;Users&lt;/code&gt; is the &lt;code&gt;ucfirst&lt;/code&gt;'ed tablename). whenever I need to have row specific model I just postfix the whole model name with &lt;code&gt;_Row&lt;/code&gt;. It gives the following directory architecture:&lt;/p&gt;

&lt;pre&gt;
modules/user/models/
	Users/Row.php
	Users.php
&lt;/pre&gt;


&lt;p&gt;I'll eventually load &lt;code&gt;User_Users_Row&lt;/code&gt; from &lt;code&gt;User/Users.php&lt;/code&gt; with a simple require:&lt;/p&gt;

&lt;pre&gt;
[php]
require_once dirname(__FILE__).'/Users/Row.php';
&lt;/pre&gt;


&lt;h3&gt;Personal library namespace&lt;/h3&gt;


&lt;p&gt;A recurring question from &lt;acronym&gt;ZF&lt;/acronym&gt; beginners is to know where they should put their own library classes. The answer is pretty simple actually. You just create your own library namespace alongside Zend's. Let's say you wish to extend &lt;code&gt;Zend_Db_Table_Abstract&lt;/code&gt; to add your own logic. The first thing to do is to choose the name of your namespace, we will use Foobar as an example, because this is a cool name. Your class will be named like &lt;code&gt;Foobar_Db_Table_Abstract&lt;/code&gt;, and located in &lt;code&gt;Foobar/Db/Table/Abstract.php&lt;/code&gt;, which in turn should be located anywhere in your &lt;code&gt;include_path&lt;/code&gt;. So you could have the following directory structure:&lt;/p&gt;

&lt;pre&gt;
application/library/
	Zend/
	Foobar/
	Riskle/
&lt;/pre&gt;


&lt;p&gt;Just remember &lt;acronym&gt;ZF&lt;/acronym&gt;'s naming convention: from the filename, strip the &lt;code&gt;.php&lt;/code&gt;, replace slashes (/) with underscores (_), and you've got the class name. Simple heh ?&lt;/p&gt;


&lt;h3&gt;App_ library namespace (App_Controller_Action, etc)&lt;/h3&gt;


&lt;p&gt;Additionnaly to my personal library namespace, I also have a special &lt;code&gt;App&lt;/code&gt; namespace, which I always locate into &lt;code&gt;application/library/App&lt;/code&gt;. This namespace principally provides two classes, &lt;code&gt;App_Controller_Action&lt;/code&gt; and &lt;code&gt;App_Db_Table_Abstract&lt;/code&gt;, which basically extend respectively &lt;code&gt;Zend_Controller_Action&lt;/code&gt; and &lt;code&gt;Zend_Db_Table_Abstract&lt;/code&gt;. All my controllers and models then use the &lt;code&gt;App_&lt;/code&gt; namespace as a reference, so that I can easily change the base class for all my controllers / models as easily as changing the parent of the corresponding &lt;code&gt;App&lt;/code&gt; class.&lt;/p&gt;


&lt;h3&gt;Using third party components&lt;/h3&gt;


&lt;p&gt;Using &lt;acronym&gt;ZF&lt;/acronym&gt; compatible components is just easy as dropping them in your include path. By &lt;acronym&gt;ZF&lt;/acronym&gt; compatible, I mean following the &lt;acronym&gt;ZF&lt;/acronym&gt; class naming convention. Just make source it's in your &lt;code&gt;include_path&lt;/code&gt;, and you can start using them right away. Components library I use includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://svn.ralphschindler.com/repo/Xend/&quot;&gt;Xend&lt;/a&gt;'s layout component&lt;/li&gt;
&lt;li&gt;Some components from &lt;a href=&quot;http://tools.assembla.com/svn/naneau_zf/library/Naneau/&quot;&gt;Naneau's library&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;My own library, &lt;a href=&quot;http://tools.assembla.com/svn/riskle/library/Riskle/&quot;&gt;Riskle&lt;/a&gt; (you'll need an &lt;a href=&quot;http://www.assembla.com/&quot;&gt;assembla&lt;/a&gt; account)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I put them in a particular path (&lt;code&gt;~/share/php/&lt;/code&gt;) which I add to my include path.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;note&lt;/strong&gt;: Some &lt;a href=&quot;http://naneau.nl/&quot;&gt;dikdiks&lt;/a&gt; tend to store third-party in &lt;code&gt;application/library/&lt;/code&gt; instead of a completely separate place. This problem looks a lot like dynamically linked vs static binaries. With static binaries (in our case, storing all in &lt;code&gt;application/library/&lt;/code&gt;), you don't have to care about dependencies, as every single needed line of code is shipped with your application. This ease redistribution and installation a lot, but makes your download larger. You also have to manage yourself dependencies upgrade (which in turn save this hassle from the end-user). With dynamically linked applications, you avoid duplicated code by forcing the use of a global, site wide, code repository (generally &lt;code&gt;/usr/share/php&lt;/code&gt; on unix systems). You also transfer dependencies handling to the end-user (and/or the packaging system). Really, this is a choice to make yourself I think.&lt;/p&gt;


&lt;p&gt;Things get a little bit more complicated when the components does not follow the naming convention. What I do in this case is just puting them into a separate directory tree called &lt;code&gt;vendor/&lt;/code&gt;, which I don't forget to add to my include path of course, then I just manually includes need files. We could have done a one-to-one match between the component's public classes and custom &lt;em&gt;well-named&lt;/em&gt; classes, but it's much of a hassle for the benefit I think.&lt;/p&gt;


&lt;h3&gt;That's all folks !&lt;/h3&gt;

&lt;p&gt;Well that's all for today. I'll try to write some more in the future about application building with the Zend Framework, there are still a lot of things to be said, invented, and discovered :-)&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/10/16/How-I-use-the-Zend-Framework#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/10/16/How-I-use-the-Zend-Framework#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1070</wfw:commentRss>
      </item>
    
  <item>
    <title>Plugin &quot;related by tags&quot; pour dotclear 2</title>
    <link>http://mirmodynamics.com/post/2007/10/04/plugin-related-by-tags-pour-dotclear-2</link>
    <guid isPermaLink="false">urn:md5:0512ecee686bfffdfce5d2a547b4b1dc</guid>
    <pubDate>Thu, 04 Oct 2007 20:50:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>dotclear2</category><category>plugin</category><category>related by tags</category>    
    <description>    &lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;: &lt;a href=&quot;http://mirmodynamics.com/post/2008/03/10/Plugin-related-by-tags-pour-dotclear-2-deuxieme&quot;&gt;nouvelle version disponible&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;Allez hop, j'ai codouillé rapidement aujourd'hui un plugin dotclear 2 pour afficher une liste des billets ayant le ou les mêmes tags que le billet en cours de lecture par l'internaute. Il est téléchargeable dès maintenant sous forme &lt;a href=&quot;http://mirmodynamics.com/public/plugin-related_by_tags-1.tar.gz&quot;&gt;d'archive tar gzipée&lt;/a&gt; ou directement de &lt;a href=&quot;http://mirmodynamics.com/public/plugin-related_by_tags-1.pkg.gz&quot;&gt;package dotclear&lt;/a&gt;. Pour l'utiliser, rien de plus simple, il suffit d'ajouter le tag suivant dans votre template, à l'endroit où vous souhaitez afficher la liste des billets:&lt;/p&gt;

&lt;pre&gt;
{{tpl:include src=&amp;quot;_related_by_tags.html&amp;quot;}}
&lt;/pre&gt;


&lt;p&gt;Et voilà c'est tout :-)&lt;/p&gt;


&lt;p&gt;Bon par contre, il faut faire gaffe a comment on tag ses billets (genre pour celui là j'ai preferré ne pas le taguer &lt;em&gt;php&lt;/em&gt; histoire d'avoir des résultats plus pertinents).&lt;/p&gt;


&lt;p&gt;ps: si quelqu'un connait un moyen d'éviter d'avoir a rajouter un bout de code au template je suis preneur (mais j'ai la flemme de chercher là tout de suite).&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/10/04/plugin-related-by-tags-pour-dotclear-2#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/10/04/plugin-related-by-tags-pour-dotclear-2#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1058</wfw:commentRss>
      </item>
    
  <item>
    <title>PDO not throwing an exception when it should</title>
    <link>http://mirmodynamics.com/post/2007/10/01/PDO-not-throwing-an-exception-when-it-should</link>
    <guid isPermaLink="false">urn:md5:60df19dc3606fa5537a420e0bd129709</guid>
    <pubDate>Mon, 01 Oct 2007 17:40:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>bug</category><category>exceptions</category><category>mysql</category><category>pdo</category><category>php</category>    
    <description>    &lt;p&gt;Today I ran into an issue that I already ran into a few weeks ago when I did not have time to dig up, but today I had this time (this plus it's a really annoying issue as you'll see). The main symptom is that PDO does not throws exceptions when you'd expect it to. It's very annoying. The reason, in my case, seems to be that I am querying an old mysql (3.23.x in my case but any 4.x will do &lt;a href=&quot;http://bugs.php.net/bug.php?id=42371&quot;&gt;according to this bug report&lt;/a&gt;). I was not able to find any info from google, so I'm posting this here so that people know :-)&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/10/01/PDO-not-throwing-an-exception-when-it-should#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/10/01/PDO-not-throwing-an-exception-when-it-should#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1054</wfw:commentRss>
      </item>
    
  <item>
    <title>New home for pagination component documentation</title>
    <link>http://mirmodynamics.com/post/2007/10/01/New-for-pagination-component-documentation</link>
    <guid isPermaLink="false">urn:md5:f869594140e39681b3570bda870b75ed</guid>
    <pubDate>Mon, 01 Oct 2007 12:44:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>assembla</category><category>pagination</category><category>php</category><category>riskle</category><category>zend framework</category>    
    <description>    &lt;p&gt;For those caring, I just posted some quick documentation for &lt;a href=&quot;http://www.assembla.com/wiki/show/riskle/Pagination_Component&quot;&gt;the pagination component at my assembla space&lt;/a&gt;. More docs will follow (including extensive phpdoc docblocks I hope).&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/10/01/New-for-pagination-component-documentation#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/10/01/New-for-pagination-component-documentation#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1053</wfw:commentRss>
      </item>
    
  <item>
    <title>Zend Framework 1.0.2 PEAR package is available</title>
    <link>http://mirmodynamics.com/post/2007/09/30/Zend-Framework-102-PEAR-package-is-available</link>
    <guid isPermaLink="false">urn:md5:06df36675496a157c1aff50b1a4f36e7</guid>
    <pubDate>Sun, 30 Sep 2007 16:21:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>package</category><category>pear</category><category>php</category><category>zend framework</category>    
    <description>    &lt;p&gt;A PEAR package for the 1.0.2 version of the Zend Framework is now available from &lt;a href=&quot;http://pear.phpmafia.net/&quot;&gt;the PEAR PHPMafia channel&lt;/a&gt;. As usual, to install just issue the following:&lt;/p&gt;

&lt;pre&gt;
[bash]
pear channel-discover pear.phpmafia.net
pear install phpmafia/Zend
&lt;/pre&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/09/30/Zend-Framework-102-PEAR-package-is-available#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/09/30/Zend-Framework-102-PEAR-package-is-available#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1051</wfw:commentRss>
      </item>
    
  <item>
    <title>Bugfixes release of Zend Framework pagination component</title>
    <link>http://mirmodynamics.com/post/2007/09/30/Bugfixes-release-of-Zend-Framework-pagination-component</link>
    <guid isPermaLink="false">urn:md5:bf8dcb74b43de25d55ba962423b5a74b</guid>
    <pubDate>Sun, 30 Sep 2007 01:28:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>assembla</category><category>pagination</category><category>php</category><category>riskle</category><category>zend framework</category><category>zend_db_table</category>    
    <description>    &lt;p&gt;I just released on &lt;a href=&quot;http://www.assembla.com/wiki/show/riskle&quot;&gt;riskle's assembla space&lt;/a&gt; a new version of my &lt;a href=&quot;http://www.assembla.com/wiki/show/riskle/Pagination_Component&quot;&gt;pagination component for the Zend Framework&lt;/a&gt; which you can download right now:&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://fashion.hosmoz.net/public/paginate-r122.tgz&quot;&gt;Riskle Paginate r122&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;This release fixes a nasty bug in &lt;code&gt;Riskle_Db_Table::fetchCols&lt;/code&gt; which prevented from retrieving the right count of cols involved in the query.&lt;/p&gt;


&lt;p&gt;The table component has also been slightly rewritten following &lt;a href=&quot;http://fashion.hosmoz.net/post/2007/09/23/Zend-Framework-Pagination-third-strike#c6892&quot;&gt;Erik's suggestion&lt;/a&gt; to move the parent mapping into &lt;code&gt;_fetch&lt;/code&gt;. The parent mapping itself has been improved to allow &amp;quot;multi level&amp;quot; table joining. This will be best explained with an example:&lt;/p&gt;


&lt;p&gt;Say you have three table, Foo, Bar and Quux, and you would like to execute the following query:&lt;/p&gt;

&lt;pre&gt;
[sql]
SELECT * FROM Foo JOIN Bar ON Foo.bar_id = Bar.id JOIN Quux ON Bar.quux_id = Quux.id
&lt;/pre&gt;


&lt;p&gt;This is now possible with the following mapping (in Foo's class of course):&lt;/p&gt;

&lt;pre&gt;
[php]
array(
    'Bar' =&amp;gt; array('local' =&amp;gt; 'bar_id', 'remote' =&amp;gt; 'id'),
    'Quux' =&amp;gt; array('local' =&amp;gt; 'quux_id', 'remote' =&amp;gt; 'Quux.id'),
);
&lt;/pre&gt;


&lt;p&gt;Easy heh ?&lt;/p&gt;


&lt;p&gt;As usual, any comments are appreciated, and please note that this code is released under the same license as the ZF itself, &lt;a href=&quot;http://framework.zend.com/license&quot;&gt;the new-bsd license&lt;/a&gt;.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/09/30/Bugfixes-release-of-Zend-Framework-pagination-component#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/09/30/Bugfixes-release-of-Zend-Framework-pagination-component#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1050</wfw:commentRss>
      </item>
    
  <item>
    <title>Of controller plugins and directory layout</title>
    <link>http://mirmodynamics.com/post/2007/09/22/A-word-on-controller-plugins</link>
    <guid isPermaLink="false">urn:md5:efefaa9aeeee587e18314a690c4ac04a</guid>
    <pubDate>Sun, 23 Sep 2007 00:55:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>controllers</category><category>directory layout</category><category>modules</category><category>plugins</category><category>zend framework</category>    
    <description>    &lt;p&gt;When anyone on #zftalk ask about where controller plugins should be kept, we usually responds something like &lt;em&gt;have your own library namesapce alongside Zend/ and put it in it like &lt;code&gt;YourNamespace/Controller/Plugin/YourPlugin.php&lt;/code&gt;&lt;/em&gt;. But what about application specific controllers ? There's a time where you have to write a plugin that relies on the application at such a level that using it elsewhere would make no sense. In that case, where can we store this plugin ? The question arised this morning, and we ended up to the fact that having a controller-level plugin directory would not hurt, after all. So one could have the following directory layout (simplified on purpose):&lt;/p&gt;

&lt;pre&gt;
/application/modules/default
    /controllers
    /library/Plugin
        MyPlugin.php
&lt;/pre&gt;


&lt;p&gt;The drawback is that in order to use autoload you would have to have each modules &lt;code&gt;Plugin&lt;/code&gt; dir in the include path, which is a bit of a hassle. Instead, we could have the much more simple folloing layout:&lt;/p&gt;

&lt;pre&gt;
/application
    library/Controller/Plugin
        MyPlugin.php
&lt;/pre&gt;


&lt;p&gt;Which is simpler but does not allow for modules specific plugins. Anyway, the former layout would require a bit more logic in the bootstrap in order to extract every modules path as plugins are registered pre-dispatch.&lt;/p&gt;


&lt;p&gt;Hope it helps with directory layout organization :-)&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;


&lt;p&gt;What I've finally decided to do is the following:&lt;/p&gt;

&lt;pre&gt;
/application
    library/App/Controller/Plugin
        MyPlugin.php
&lt;/pre&gt;


&lt;p&gt;So that application specific code gets prefixed with the &lt;code&gt;App_&lt;/code&gt; namespace.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/09/22/A-word-on-controller-plugins#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/09/22/A-word-on-controller-plugins#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1038</wfw:commentRss>
      </item>
    
</channel>
</rss>