<?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>Elendev&#039;s developments</title>
	<atom:link href="http://blog.elendev.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.elendev.com</link>
	<description>Lots of cool (technical) stuff</description>
	<lastBuildDate>Wed, 20 Feb 2013 08:10:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>Widget management bundle for Symfony 2 / Twig</title>
		<link>http://blog.elendev.com/development/php/widget-management-bundle-for-symfony-2-twig/</link>
		<comments>http://blog.elendev.com/development/php/widget-management-bundle-for-symfony-2-twig/#comments</comments>
		<pubDate>Wed, 20 Feb 2013 08:10:46 +0000</pubDate>
		<dc:creator>Elendev</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony 2]]></category>

		<guid isPermaLink="false">http://blog.elendev.com/?p=364</guid>
		<description><![CDATA[Like every developer, I like to have the most beautiful architecture when I work on a project. For me, a beautiful architecture allow me to add useful informations on views withouth dependencies. For example : an administration page show every action possible, like simple member edition features. When a new bundle is added to the &#8230; </p><p><a class="more-link block-button" href="http://blog.elendev.com/development/php/widget-management-bundle-for-symfony-2-twig/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>Like every developer, I like to have the most beautiful architecture when I work on a project.</p>
<p>For me, a beautiful architecture allow me to add useful informations on views withouth dependencies. For example : an administration page show every action possible, like simple member edition features. When a new bundle is added to the project, it should automatically add possible actions (widgets) in administration page, like the <em>Parameters</em> app in iOS. This bundle should also be removable withouth any modifications on other bundles code.</p>
<p>To do so, I created <em><a title="ElendevWidgetBundle" href="https://github.com/Elendev/ElendevWidgetBundle" target="_blank">ElendevWidgetBundle</a></em>, This bundle provide a simple twig method which include widgets in templates. The widgets are identified with a <em>tag</em> and are added to specifics places on views.</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div&gt;My template with some html...&lt;/div&gt;
&lt;div&gt;My widgets place : {{ widgets('my_tag') }}&lt;/div&gt;
&lt;div&gt;End of my template...&lt;/div&gt;</pre></td></tr></table></div>

<p>In the example above, every widget with the tag <em>my_tag</em> is added in the view. The widget is a simple tagged service method.</p>
<p>This bundle allow to create widgets places in existing views and when a new feature is added, it can plug widgets everywhere it&#8217;s needed withouth current view modification.</p>
<p>For more informations, you can take a look at the <a title="ElendevWidgetBundle" href="https://github.com/Elendev/ElendevWidgetBundle" target="_blank">ElendevWidgetBundle&#8217;s GitHub</a>.<br />
&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elendev.com/development/php/widget-management-bundle-for-symfony-2-twig/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Frtrains&#8217; e-commerce : Shop v2</title>
		<link>http://blog.elendev.com/uncategorized/frtrains-e-commerce-shop-v2/</link>
		<comments>http://blog.elendev.com/uncategorized/frtrains-e-commerce-shop-v2/#comments</comments>
		<pubDate>Wed, 16 Jan 2013 16:36:59 +0000</pubDate>
		<dc:creator>Elendev</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.elendev.com/?p=352</guid>
		<description><![CDATA[Frtrains.com is a website about trains (mainly french and swiss trains). You will find some articles about trains, but first of all, you&#8217;ll be able to buy trains through the Shop. The first version was quite old and I&#8217;ve worked hard to develop a version 2. Now the Shop v2 is out and in production, using Symfony2. &#8230; </p><p><a class="more-link block-button" href="http://blog.elendev.com/uncategorized/frtrains-e-commerce-shop-v2/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p><a title="frtrains.com" href="http://www.frtrains.com" target="_blank">Frtrains.com</a> is a website about trains (mainly french and swiss trains). You will find some articles about trains, but first of all, you&#8217;ll be able to buy trains through the <a title="Shop Frtrains" href="https://www.frtrains.com/shop" target="_blank">Shop</a>.</p>
<p>The first version was quite old and I&#8217;ve worked hard to develop a version 2. Now the Shop v2 is out and in production, using Symfony2.</p>
<p>For more informations, you can read <a title="Frtrains’ e-commerce : Shop" href="http://blog.elendev.com/frtrains-shop/">this</a>.</p>
<p>Take a look and maybe buy something ^^</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elendev.com/uncategorized/frtrains-e-commerce-shop-v2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AppManagerBundle</title>
		<link>http://blog.elendev.com/development/php/symfony/appmanagerbundle/</link>
		<comments>http://blog.elendev.com/development/php/symfony/appmanagerbundle/#comments</comments>
		<pubDate>Tue, 11 Dec 2012 13:09:50 +0000</pubDate>
		<dc:creator>Elendev</dc:creator>
				<category><![CDATA[Symfony 2]]></category>
		<category><![CDATA[application management]]></category>
		<category><![CDATA[AppManager]]></category>
		<category><![CDATA[Bundle]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP 5.3]]></category>
		<category><![CDATA[php5.3]]></category>
		<category><![CDATA[Symfony2]]></category>

		<guid isPermaLink="false">http://blog.elendev.com/?p=337</guid>
		<description><![CDATA[Presentation The AppManager help you manage your application. You can have multiple versions of an application online (for tests and rollback purpose), the App Manager allow you to choose which one is the one in production. This application is really useful in mutual hosting, where you can&#8217;t go with SSH to launch Symfony2 commands. You &#8230; </p><p><a class="more-link block-button" href="http://blog.elendev.com/development/php/symfony/appmanagerbundle/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<h1>Presentation</h1>
<p>The AppManager help you manage your application. You can have multiple versions of an application online (for tests and rollback purpose), the App Manager allow you to choose which one is the one in production.</p>
<p>This application is really useful in mutual hosting, where you can&#8217;t go with SSH to launch Symfony2 commands. You are able to clear/warmup cache, dump assets, install assetics directly from the web interface.</p>
<p>In other words : you can easily have a good control of your application.</p>
<h1>Current status</h1>
<p>The AppManagerBundle is actually under heavy developments but is already used on production. I will provide a standalone application (provide a symfony2 application including AppManagerBundle) as soon as the bundle is table enough.</p>
<h1>Official informations</h1>
<p>To keep as much as possible informations in the same place, I decided to create the official application page on GitHub instead of having a page on my blog. For more informations, you can go to the official <a title="appManagerBundle" href="http://elendev.github.com/ElendevAppManagerBundle/" target="_blank">project page</a> or access directly the <a title="ElendevAppManagerBundle" href="https://github.com/Elendev/ElendevAppManagerBundle" target="_blank">GitHub repository</a>.</p>
<p>Enjoy !</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elendev.com/development/php/symfony/appmanagerbundle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving to GitHub</title>
		<link>http://blog.elendev.com/development/moving-to-github/</link>
		<comments>http://blog.elendev.com/development/moving-to-github/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 06:57:39 +0000</pubDate>
		<dc:creator>Elendev</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Symfony 2]]></category>
		<category><![CDATA[Bundle]]></category>
		<category><![CDATA[ElendevCheckoutBundle]]></category>
		<category><![CDATA[ElendevImageBundle]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony2]]></category>

		<guid isPermaLink="false">http://blog.elendev.com/?p=307</guid>
		<description><![CDATA[For my projects (actually the two Symfony 2 bundles I develop, ElendevImageBundle and ElendevCheckoutBundle), I used Google Code under Git as source management. Lots of projects I use (Symfony 2 and some Symfony 2 bundles) use GitHub. Version 2.1 of Symfony now use Composer as dependency manager and Composer use mainly http://packagist.org/ as repository. I found that &#8230; </p><p><a class="more-link block-button" href="http://blog.elendev.com/development/moving-to-github/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>For my projects (actually the two Symfony 2 bundles I develop, ElendevImageBundle and ElendevCheckoutBundle), I used Google Code under Git as source management.</p>
<p>Lots of projects I use (Symfony 2 and some Symfony 2 bundles) use GitHub. Version 2.1 of Symfony now use Composer as dependency manager and Composer use mainly <a href="http://packagist.org/">http://packagist.org/</a> as repository.</p>
<p>I found that packagist can use GitHub to provide packages and the final goal is to provide my bundles through Composer to make them easier to include into applications.</p>
<h3> New access</h3>
<p>You can now access the ElendevCheckoutBundle at <a href="https://github.com/Elendev/ElendevCheckoutBundle">https://github.com/Elendev/ElendevCheckoutBundle</a>.</p>
<p>And the ElendevImageBundle at <a href="https://github.com/Elendev/ElendevImageBundle">https://github.com/Elendev/ElendevImageBundle</a>.</p>
<p>The both pages (<a title="Symfony 2 ElendevCheckoutBundle" href="http://blog.elendev.com/symfony-2-elendevcheckoutbundle/">ElendevCheckoutBundle </a>and <a title="Symfony 2 ElendevImageBundle" href="http://blog.elendev.com/symfony-2-elendevimagebundle/">ElendevImageBundle</a>)  are updated with new configuration.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elendev.com/development/moving-to-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Plevin : routing mechanism</title>
		<link>http://blog.elendev.com/development/php/plevin/plevin-routing-mechanism/</link>
		<comments>http://blog.elendev.com/development/php/plevin/plevin-routing-mechanism/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 15:11:00 +0000</pubDate>
		<dc:creator>Elendev</dc:creator>
				<category><![CDATA[Plevin]]></category>
		<category><![CDATA[home made framework]]></category>
		<category><![CDATA[PHP 5.3]]></category>
		<category><![CDATA[routing]]></category>

		<guid isPermaLink="false">http://blog.elendev.com/?p=130</guid>
		<description><![CDATA[Introduction In this article I&#8217;ll present the routing mechanism inside my home-made php framework : Plevin. The routing mechanism inside Plevin is quite simple. Every controller (named here handler) is market with an annotation and a file is generated at website initialisation. Controller (handler) class Here you can see a simple example of controller. The &#8230; </p><p><a class="more-link block-button" href="http://blog.elendev.com/development/php/plevin/plevin-routing-mechanism/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>In this article I&#8217;ll present the routing mechanism inside my home-made php framework : Plevin.</p>
<p>The routing mechanism inside Plevin is quite simple. Every controller (named here <em>handler</em>) is market with an annotation and a file is generated at website initialisation.</p>
<h1>Controller (handler) class</h1>
<p>Here you can see a simple example of controller. The <em>CategoryHandler</em> class is marked as handler and manage specified urls.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * @HandleURL(pattern=&quot;/categories&quot;)
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> CategoryHandler<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * @Injection(id=&quot;Logger&quot;)
     * @var Plevin\logging\Logger
     */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$logger</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @HandleURL(pattern=&quot;/$&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> showMain<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Show main page&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @HandleURL(pattern=&quot;/{category}&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> showCategory<span style="color: #009900;">&#40;</span><span style="color: #000088;">$categoryName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;main&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Template content for category <span style="color: #006699; font-weight: bold;">$categoryName</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Show the specified object, from the specified category
     * @HandleURL(pattern=&quot;/{category}/{object}$&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> showObject<span style="color: #009900;">&#40;</span><span style="color: #000088;">$categoryName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$objectName</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Template content for category <span style="color: #006699; font-weight: bold;">$categoryName</span>, object <span style="color: #006699; font-weight: bold;">$objectName</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The handler class has a function for every managed url. Each function can receive url parameters and have to generate a template.</p>
<p>In the example above a simple injection is made, the handler receive a reference to the framework&#8217;s logger.</p>
<h1>Generated file</h1>
<p>On first execution, the <em>CategoryHandler</em> is analysed and the corresponding generated cached file is visible here :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;@^/categories@&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/path/to/app/Site/handler/CategoryHandler.php&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">filemtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">filemtime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/path/to/app/Site/handler/CategoryHandler.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> \Plevin\cache\CacheOutOfDateException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Class Shop2\handler\CategoryHandler out of date !&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;@^/categories/$@&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$injection</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Plevin\injection\InjectionProxy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;\handler\CategoryHandler&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">array_shift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$injection</span><span style="color: #339933;">-&gt;</span>__call<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;showMain&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;@^/categories/((?:[a-zA-Z0-9]|_|-)+)$@&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$injection</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Plevin\injection\InjectionProxy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;\handler\CategoryHandler&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">array_shift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$injection</span><span style="color: #339933;">-&gt;</span>__call<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;showCategory&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;@^/categories/((?:[a-zA-Z0-9]|_|-)+)/((?:[a-zA-Z0-9]|_|-)+)$@&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$injection</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Plevin\injection\InjectionProxy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;\handler\CategoryHandler&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">array_shift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$injection</span><span style="color: #339933;">-&gt;</span>__call<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;showObject&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>First of all, the generated file check if the handler has been modified since last file generation. When the generated file is older than the handler, an <em>CacheOutOfDateException</em> is thrown and the framework generate a new cache file.</p>
<p>The controller routing is managed with some simple <em>preg_match</em> function. Before any call to the handler&#8217;s method, a new instance of <em>InjectionProxy</em> is created and the correct handler&#8217;s method class is made through the newly generated <em>InjectionProxy</em>. Every dependency injection is managed by the <em>InjectionProxy</em> (in this case, the logger is injected if necessary). For more informations about dependency injection, an article will be available soon.</p>
<p>The generated file return true when an url is recognized and managed by a handler. When no handler manage a given url, false is returned and a simpl 404 error is generated.</p>
<h1>Link creation</h1>
<p>Plevin framework provide a great flexibility in link management. A link to a specific page is a link to a specific controller&#8217;s method with specific parameters. An <em>URLManager</em> is provided to help developer creating links. The code below show how to create a link to a specific controller&#8217;s method :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * @HandleURL(pattern=&quot;/inscription&quot;)
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> InscriptionHandler <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @Injection(id=&quot;URLManager&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$urlManager</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @HandleURL(pattern=&quot;/$&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> showInscriptionForm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #339933;">...</span>
        <span style="color: #000088;">$link</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">urlManager</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getURL</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;App\handler\CategoryHandler-&gt;showCategory&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;category&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$currentCategory</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #339933;">...</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>In the code above, the <em>$link</em> variable contains the path to the <em>showCategory()</em> method of the <em>CategoryHandler</em> controller. When urls contain parameters, they can be given through <em>getURL()</em> second argument.</p>
<p>The generated url is based on the <em>@HandleURL</em> annotation of the targeted method.</p>
<h1>Conclusion</h1>
<p>The url management provided by Plevin is flexible enough to change easly controllers&#8217; paths. The main disadvantage of this operating way is the high dependency to the destination handler&#8217;s name (on refactoring you have to recreate every links).</p>
<p>A better method is the one used by Symfony 2 : an url file containing an id for every link. Every id target a controller&#8217;s method and links are made with a reference to a specific id.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elendev.com/development/php/plevin/plevin-routing-mechanism/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checkout management bundle for Symfony 2</title>
		<link>http://blog.elendev.com/development/php/symfony/checkout-management-bundle-for-symfony-2/</link>
		<comments>http://blog.elendev.com/development/php/symfony/checkout-management-bundle-for-symfony-2/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 08:45:18 +0000</pubDate>
		<dc:creator>Elendev</dc:creator>
				<category><![CDATA[Symfony 2]]></category>
		<category><![CDATA[Bundle]]></category>
		<category><![CDATA[Checkout]]></category>
		<category><![CDATA[Checkout bundle]]></category>
		<category><![CDATA[CheckoutBundle]]></category>
		<category><![CDATA[Google Checkout]]></category>
		<category><![CDATA[Paypal]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[Symfony2]]></category>

		<guid isPermaLink="false">http://blog.elendev.com/?p=271</guid>
		<description><![CDATA[Introduction I actually work, on my spare-time, on an e-commerce website. As I had to implement Paypal ExpressCheckout payment method and because I didn&#8217;t found any CheckoutBundle matching to my needs, I decided to create one and to provide it with Apache 2 licence. Thus was born ElendevCheckoutBundle. This bundle is still under development and &#8230; </p><p><a class="more-link block-button" href="http://blog.elendev.com/development/php/symfony/checkout-management-bundle-for-symfony-2/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>I actually work, on my spare-time, on an e-commerce website. As I had to implement Paypal ExpressCheckout payment method and because I didn&#8217;t found any CheckoutBundle matching to my needs, I decided to create one and to provide it with Apache 2 licence. Thus was born ElendevCheckoutBundle.</p>
<p>This bundle is still under development and only Paypal ExpressCheckout is provided. The ElendevCheckoutBundle bundle can support lots of checkout services and I plan to implement Google Checkout API and eventually Swiss post payment API.</p>
<p>The ElendevCheckoutBundle is available on <a title="ElendevCheckoutBundle's google code" href="http://code.google.com/p/elendev-checkout-bundle/" target="_blank">google code</a> and more informations are available at <a title="Symfony 2 ElendevCheckoutBundle" href="http://blog.elendev.com/symfony-2-elendevcheckoutbundle/">ElendevCheckoutBundle page</a>.</p>
<h1>Conclusion</h1>
<p>The ElendevCheckoutBundle is still under heavy development but it&#8217;s already used on some of my projects. I plan to extend the bundle and add as much checkout services as possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elendev.com/development/php/symfony/checkout-management-bundle-for-symfony-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Image management bundle for Symfony 2 / Twig</title>
		<link>http://blog.elendev.com/development/php/symfony/image-management-bundle-for-symfony-2-twig/</link>
		<comments>http://blog.elendev.com/development/php/symfony/image-management-bundle-for-symfony-2-twig/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 13:02:48 +0000</pubDate>
		<dc:creator>Elendev</dc:creator>
				<category><![CDATA[Symfony 2]]></category>
		<category><![CDATA[ElendevImageBundle]]></category>
		<category><![CDATA[Image management]]></category>
		<category><![CDATA[ImageBundle]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP 5.3]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[Symfony 2 bundle]]></category>
		<category><![CDATA[Symfony2]]></category>

		<guid isPermaLink="false">http://blog.elendev.com/?p=211</guid>
		<description><![CDATA[Introduction During works on some websites, I often encountered the necessity to create thumbnails of existing images. Its allways the same problem : I need to save thumbnails on some specific directories, manage thumbnails creations on file upload and so on. So I decided to create the ElendevImageBundle for Symfony 2. The template designer specify &#8230; </p><p><a class="more-link block-button" href="http://blog.elendev.com/development/php/symfony/image-management-bundle-for-symfony-2-twig/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>During works on some websites, I often encountered the necessity to create thumbnails of existing images. Its allways the same problem : I need to save thumbnails on some specific directories, manage thumbnails creations on file upload and so on. So I decided to create the ElendevImageBundle for Symfony 2.</p>
<p>The template designer specify the image properties (size, rotation, grey scale or colored, &#8230;) and a corresponding image file is generated and saved in a cache directory. Every further call of same image with same properties returns the previously cached file.</p>
<p>It&#8217;s designed to be very efficient. You can find more informations on the dedicated page of <a title="Symfony 2 ElendevImageBundle" href="http://blog.elendev.com/symfony-2-elendevimagebundle/">ElendevImageBundle</a>.</p>
<h1>Conclusion</h1>
<p>The ElendevImageBundle is still under development but the actual ElendevImageBundle is already used on some of my projects. It&#8217;s an easy way to manage image (particulary image resizing) regardless of new image files storage or specific image size management.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elendev.com/development/php/symfony/image-management-bundle-for-symfony-2-twig/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A home made PHP framework : Plevin</title>
		<link>http://blog.elendev.com/development/php/plevin/a-home-made-php-framework-plevin/</link>
		<comments>http://blog.elendev.com/development/php/plevin/a-home-made-php-framework-plevin/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 15:11:52 +0000</pubDate>
		<dc:creator>Elendev</dc:creator>
				<category><![CDATA[Plevin]]></category>
		<category><![CDATA[annotations]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mvc framework]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP 5.3]]></category>
		<category><![CDATA[php annotations]]></category>
		<category><![CDATA[PHP framework]]></category>
		<category><![CDATA[PHP mvc]]></category>

		<guid isPermaLink="false">http://blog.elendev.com/?p=99</guid>
		<description><![CDATA[Introduction Plevin means Plug Evolution In. It&#8217;s a little bit pretentious but when I started working on it I had a lot of ambitions. I&#8217;ve done a lot of great work around my home made MVC framework in PHP but I had a severe lack of time. The framework have never been finished but there &#8230; </p><p><a class="more-link block-button" href="http://blog.elendev.com/development/php/plevin/a-home-made-php-framework-plevin/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>Plevin means Plug Evolution In. It&#8217;s a little bit pretentious but when I started working on it I had a lot of ambitions. I&#8217;ve done a lot of great work around my home made MVC framework in PHP but I had a severe lack of time.</p>
<p>The framework have never been finished but there is a lot of good ideas I haven&#8217;t founded in other PHP frameworks. That&#8217;s why I will make articles presenting some of the main concepts of Plevin framework, focusing on some difficulties I&#8217;ve encountered and solutions I&#8217;ve founded.</p>
<p>I&#8217;ve initially based my work on Spring and JEE frameworks, using annotations in PHP class. At the time I&#8217;ve began working on this framework, PHP 5.3 just came out and provided very useful features like namespace support.</p>
<h1>Annotation based configuration</h1>
<p>Java, unlike PHP, support annotations in the code. Nevertheless, a simple way to use annotations in PHP is to use commented annotations. Annotations are added through comments (PHPComments, working like javadoc comments) and a simple parser is used to parse the class code and analyse annotations.</p>
<p>Every class (like controllers and available services) are marked with commented annotations. On first execution every file is scanned and annotations are analysed and saved into cached files. A simple example of commented annotations is visible here :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * @HandleURL(pattern=&quot;/categories&quot;)
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> CategoryHandler<span style="color: #009900;">&#123;</span>
    <span style="color: #339933;">...</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h1>Cache system</h1>
<p>Because of the lack of performance of PHP, the Plevin framework is based on a cache system. Every configuration (like class annotations, configuration file) is analysed and a cached version is created (most of the time it&#8217;s a simple PHP file with information in an array). A template system is available with fully cached translation system. Every page is created and cached in every language. When translation files are modified, the modified time is compared to the cached file creation time. When the cached file is older than the modified file, a new cached file is created.</p>
<p>The routing system is also based on cache. Every controller has an annotation containing the handled path. On first script execution, a cache file is created containing all available path routing to correct controller.</p>
<h1>Dependency injection</h1>
<p>An other important feature is the dependency injection system. This system is an annotation based dependency injection system. Every controllers and <em>beans</em> can add PHP annotations on member to have dependency injection (like <em>@Autowire</em> in Spring).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> CategoryHandler<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * @Injection(id=&quot;Logger&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$logger</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #339933;">...</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>A configuration file contain services declaration :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;lookupClasses<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;instance</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;EntityManager&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;Plevin\db\ConfigAutoloadEntityManager&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;instance</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;TemplateFactory&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;Plevin\template\CacheLangTemplateFactory&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;instance</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;LanguageProvider&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;Plevin\language\Language&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;instance</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;PathManager&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;Plevin\DefaultPathManager&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;instance</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;URLManager&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;Plevin\url\DefaultURLManager&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;instance</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;SessionService&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;Plevin\session\SessionService&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;instance</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;Logger&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;Plevin\logging\Logger&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;instance</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;Translator&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;Plevin\language\DefaultTranslator&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/lookupClasses<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Many options exists for services, like <em>statefull</em> or <em>stateless</em> status. An article will be dedicated to the dependency injection mechanism.</p>
<h1>Template system</h1>
<p>A simple home made template engine is used to optimize translation system. A template file is <em>compiled</em> and cached for every available language. The template engine need to translate file only once per language. Some <em>macros</em> are also available, like <em>__INSERT(&#8230;)__</em>. The code below is a simple template example :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">__INSERT(&quot;/main/template_header.html&quot;)__
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;table</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
__INSERT(&quot;/category/object_item.html&quot;)__
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td</span> <span style="color: #000066;">colspan</span>=<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>__TECHNICAL_INFORMATION__ :<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td</span> <span style="color: #000066;">colspan</span>=<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> echo $object-<span style="color: #000000; font-weight: bold;">&gt;</span></span>getMainDescription();?&gt;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
__INSERT(&quot;/main/template_footer.html&quot;)__</pre></td></tr></table></div>

<h1>ORM</h1>
<p>When I began the Plevin framework there was no class oriented ORM working with getters and setters, like JPA. I decided to create my own ORM layer, at first based on XML files for model description and, later, on class annotations. Class declaration and simple relations (one-to-one, one-to-many, many-to-one, bidirectionnal one-to-many) works well, database is correctly generated.</p>
<p>The difficulties arrived when I decided to implement bidirectional many-to-many relations with eager / lazy initialisation system and heritage.</p>
<p>At the same time, Doctrine 2 passed on beta version and is exactly what I was expecting from an ORM. I replaced the home made ORM with Doctrine 2.</p>
<h1>Conclusion</h1>
<p>Finally, Symfony 2 came out with lots of features I expected. Idecided to use it, mainly because of the Symfony 2 community support (managing a complete framework is a time-consuming task).</p>
<p>The work I&#8217;ve done on my home made framework wasn&#8217;t useless because I&#8217;ve learned a lots of things, that&#8217;s why I&#8217;ve decided to share my experience on my blog. I will write some articles to present some specific parts of Plevin.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elendev.com/development/php/plevin/a-home-made-php-framework-plevin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 browser storage &#8211; State of the art</title>
		<link>http://blog.elendev.com/development/html5-javascript/html5-browser-storage-state-of-the-art/</link>
		<comments>http://blog.elendev.com/development/html5-javascript/html5-browser-storage-state-of-the-art/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 12:07:10 +0000</pubDate>
		<dc:creator>Elendev</dc:creator>
				<category><![CDATA[HTML5 / JavaScript]]></category>
		<category><![CDATA[browser storage]]></category>
		<category><![CDATA[html 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[indexeddb]]></category>
		<category><![CDATA[localstorage]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://blog.elendev.com/?p=57</guid>
		<description><![CDATA[Introduction As you certainly know, HTML5 bring some very useful features for web applications, like socket connection or browser storage capabilities. In this article, I make some kind of state of the art about browser storage capabilities. If you plan to save data on a browser, there is three possibilities : LocalStorage, SQLite and IndexedDB. &#8230; </p><p><a class="more-link block-button" href="http://blog.elendev.com/development/html5-javascript/html5-browser-storage-state-of-the-art/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>As you certainly know, HTML5 bring some very useful features for web applications, like socket connection or browser storage capabilities. In this article, I make some kind of state of the art about browser storage capabilities.</p>
<p>If you plan to save data on a browser, there is three possibilities : LocalStorage, SQLite and IndexedDB. You probably want to know which one to choose. There is actually no right or wrong response. First of all, I will describe every possibility with it&#8217;s advantages and disadvantages.</p>
<h1>LocalStorage</h1>
<p>The LocalStorage object is a simple key =&gt; value store. The key and the value are simple strings, it works like a dictionnary.</p>
<p>The main advantages of the LocalStorage is it&#8217;s simplicity and it&#8217;s support on lots of browsers.</p>
<p>The main disadvantage of the LocalStorage is it&#8217;s little storage capacity. After some little benchmarks, we can&#8217;t save up to 5MB of data.</p>
<h1>SQLite</h1>
<p>SQLite was, at first, designed as the de-facto browser storage standard. Now, the W3C don&#8217;t support SQLite anymore. The main reason is the incapacity for them to use a standard instead of an application. Lots of browsers where implementing a SQLite database accessible with JavaScript but the W3C wanted a standard describing the SQL language and the provided JavaScript API. There is a JavaScript API but no one were able to provide a SQL standard. Finally, the W3C don&#8217;t support the SQLite as browser storage anymore but it&#8217;s still implemented in some browsers. SQLite can save up to 1Go data on a desktop computer and up to 50MB data on a smartphone (depending on the browser configuration).</p>
<p>The main advantage of SQLite is it&#8217;s availability (it&#8217;s provided by mobile browsers on Android and iOS, by PhoneGap for mobile applications and by Chrome 15 and Safari 5).</p>
<p>The main disadvantage of SQLite is that the W3C don&#8217;t support SQLite anymore and some browsers, like Firefox, removed the SQLite support in their last versions.</p>
<h1>IndexedDB</h1>
<p>IndexedDB is the new standard provided by the W3C. It&#8217;s not a relationnal database but it&#8217;s a document based database. A database is composed of multiple stores, every store contain data in key =&gt; value format. The data are saved in object format. It&#8217;s possible, for the developer, to make a query on some specific properties of an object to get them back. Actually, Chrome 15 and Firefox 8 have an implementation of IndexedDB but the implementations are quite different. A script using IndexedDB on Chrome don&#8217;t work on Firefox and vice versa. The IndexedDB standard isn&#8217;t completely done and the API is still changing.</p>
<p>The main advantages of IndexedDB is the support of the W3C and it&#8217;s capability to save directly JavaScript objects instead of serialized objects and the capability to create request on saved objects.</p>
<p>The main disadvantage of IndexedDB is it&#8217;s young age : the standard is still changing and IndexedDB is only implemented in few browsers.</p>
<h1>Conclusion</h1>
<p>The next picture show the browser supports for LocalStorage, SQLite and IndexedDB.</p>
<div id="attachment_66" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.elendev.com/wp-content/uploads/2011/12/localStorageBrowserSupport.png"><img class="size-medium wp-image-66" title="localStorageBrowserSupport" src="http://blog.elendev.com/wp-content/uploads/2011/12/localStorageBrowserSupport-300x196.png" alt="Local storage support by browser" width="300" height="196" /></a><p class="wp-caption-text">Actual support of HTML5 browser storage by browser</p></div>
<p>The better solution actually is to use an intermediate layer for browser storage, supporting SQLite, LocalStorage and (in the futur) IndexedDB. In this way, developers will be able to create web application using browser storage capabilities with enough flexibility to work on every modern browser.</p>
<p>I&#8217;ve already developed an intermediate layer with query capabilities and I will introduce it in a next article.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elendev.com/development/html5-javascript/html5-browser-storage-state-of-the-art/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring 3 mvc and JSON (with Jackson)</title>
		<link>http://blog.elendev.com/development/java/spring/spring-3-mvc-and-json-with-jackson/</link>
		<comments>http://blog.elendev.com/development/java/spring/spring-3-mvc-and-json-with-jackson/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 07:36:39 +0000</pubDate>
		<dc:creator>Elendev</dc:creator>
				<category><![CDATA[Spring]]></category>
		<category><![CDATA[jackson]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[spring 3]]></category>
		<category><![CDATA[spring mvc]]></category>

		<guid isPermaLink="false">http://blog.elendev.com/?p=13</guid>
		<description><![CDATA[Introduction Spring 3 is quite new and seems to support MVC and JSON with no configurations. That&#8217;s unfortunately not totaly exact. Spring 3 support JSON with few configurations, but not withouth any configuration. JSON library dependency First of all, a JSON library is needed. Here I use Jackson as JSON conversion service. If you don&#8217;t &#8230; </p><p><a class="more-link block-button" href="http://blog.elendev.com/development/java/spring/spring-3-mvc-and-json-with-jackson/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>Spring 3 is quite new and seems to support MVC and JSON with no configurations. That&#8217;s unfortunately not totaly exact. Spring 3 support JSON with few configurations, but not withouth any configuration.</p>
<h1>JSON library dependency</h1>
<p>First of all, a JSON library is needed. Here I use <a href="http://jackson.codehaus.org/" target="_blank">Jackson</a> as JSON conversion service. If you don&#8217;t use maven, you just have to add Jackson jars and it&#8217;s dependencies to your path. If you use maven, you need to add this dependency on your pom.xml :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.codehaus.jackson<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jackson-jaxrs<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.9.2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<div class="notice_block message-block"><p class="printonly"><strong>Notice</strong></p>The dependency need to be added on the pom.xml of the main project. Jackson wasn&#8217;t working the first time I&#8217;ve configured my project because I&#8217;ve included Jackson on the <em>pom.xml</em> of a subproject. The subproject was included as a dependency for the main project and the Jackon&#8217;s jars were correctly available for the subproject, but Spring wasn&#8217;t able to use it, although the controller was in the subproject.</div>
<h1>Spring configuration : appContext.xml</h1>
<p>The second step is to tell Spring to look for annotations for mvc. Spring 3 will check Jackson package, find a correct conversion service and use it to return correct JSON objects. The file context.xml need to contain the <em></em> tag <em></em> :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">xmlns:mvc</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/mvc&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">        http://www.springframework.org/schema/beans </span>
<span style="color: #009900;">        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd</span>
<span style="color: #009900;">        http://www.springframework.org/schema/mvc </span>
<span style="color: #009900;">        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #808080; font-style: italic;">&lt;!-- enable automatic check for conversion service --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mvc:annotation-driven</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<h1>Spring controller</h1>
<p>Now, you are ready to return POJO on your controller class with <em>@ResponseBody</em> annotation. The <em>@RequestBody</em> annotation can be used to get directly POJOs from JSON input, automatically converted.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">@Controller
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyController <span style="color: #009900;">&#123;</span>
    @RequestMapping<span style="color: #009900;">&#40;</span>value <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/someWhere&quot;</span>, method <span style="color: #339933;">=</span> RequestMethod.<span style="color: #006633;">GET</span><span style="color: #009900;">&#41;</span>
    @ResponseBody
    <span style="color: #000000; font-weight: bold;">public</span> TestClass getSomeTestClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        TestClass response <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TestClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> response<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @RequestMapping<span style="color: #009900;">&#40;</span>value <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/someArguments&quot;</span>, method <span style="color: #339933;">=</span> RequestMethod.<span style="color: #006633;">Post</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> saveSomeTestClass<span style="color: #009900;">&#40;</span>@RequestBody TestClass myClass<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//do somme stuff with myClass</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>With the few configuration described in this article, Spring work well with JSON.</p>
<div class="notice_block message-block"><p class="printonly"><strong>Notice</strong></p>If you still can&#8217;t get JSON from Spring 3 with your browser, it&#8217;s could be because of the HTTP <em>Accept</em> header. Normally, the browser don&#8217;t send <em>Accept:application/json</em> to the server and the server will not generate JSON. To avoid this, you can use a simple <em>jQuery</em> script sending <em>Accept:application/json</em> headers and showing response or you can install JSONView plugin on Firefox and check the <em>Include &#8220;application/json&#8221; in the HTTP Accept header for request</em> checkbox. JSONView is available for Google Chrome but this option isn&#8217;t available on Chrome.<br />
</div>
<div id="attachment_19" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.elendev.com/wp-content/uploads/2011/12/jsonviewconfig.png"><img class="size-medium wp-image-19" title="jsonviewconfig" src="http://blog.elendev.com/wp-content/uploads/2011/12/jsonviewconfig-300x158.png" alt="JSONView config" width="300" height="158" /></a><p class="wp-caption-text">JSONView configuration</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.elendev.com/development/java/spring/spring-3-mvc-and-json-with-jackson/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
