<?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>Nerdpress.org &#187; Ivo Bathke</title>
	<atom:link href="http://nerdpress.org/author/ivo-bathke/feed/" rel="self" type="application/rss+xml" />
	<link>http://nerdpress.org</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Mon, 30 Jan 2012 14:28:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Silex and MongoDB simply</title>
		<link>http://nerdpress.org/2012/01/30/silex-and-mongodb-simply/</link>
		<comments>http://nerdpress.org/2012/01/30/silex-and-mongodb-simply/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 14:27:34 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[Doctrine ORM]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Silex]]></category>
		<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[silex]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=2033</guid>
		<description><![CDATA[Using MongoDB in your Silex Project is quite easy. I will show this with my Superleansilexplate and will integrate it there as an example. Since i dont want to integrate MongoDB in Superleansilexplate it will just become an additional gist. Given you have some smaller amount of data like a counter that needs to be [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Using MongoDB in your Silex Project is quite easy.</p>
<p>I will show this with my <a href="https://github.com/ivoba/superleansilexplate">Superleansilexplate</a> and will integrate it there as an example.<br />
Since i dont want to integrate MongoDB in Superleansilexplate it will just become an additional <a href="https://gist.github.com/1704512">gist</a>.</p>
<p>Given you have some smaller amount of data like a counter that needs to be stored or other loose coupled datasets, we simply speak to MongoDB &#8220;directly&#8221; and store the data via <a href="https://github.com/doctrine/mongodb">Doctrine MongoDB Abstraction Layer</a>.<br />
Since i presume the Data / Document Structure isnt that complex we dont use <a href="https://github.com/doctrine/mongodb-odm">Doctrine MongoDB ODM</a> (the Object Document Mapper).<br />
If you want to use it instead, try this <a href="https://github.com/docteurklein/SilexExtensions">Silex Extensions</a>.</p>
<p><span id="more-2033"></span></p>
<p>So we use this <a href="https://github.com/fate/Silex-Extensions">SilexExtensions</a> collection and install it via git:</p>
<pre class="brush: bash; title: ; notranslate">
 cd mysilexproject
 git clone git@github.com:fate/Silex-Extensions.git vendor/silex-extension
</pre>
<p>Then we install the doctrine mongodb libary manually:</p>
<pre class="brush: bash; title: ; notranslate">
 git clone --recursive https://github.com/doctrine/mongodb vendor/mongodb
</pre>
<p>The extension collection has some more poviders but you can just ignore them and just focus on the MongoDbExtension.</p>
<p>-<em> i actually dont like extensions collections. i would prefer to clone each extensions individually. thou its not much code overhead, but when it comes to the vendor dependencies it can become quite messy IMHO</em> -</p>
<p>Alright now the code.<br />
Edit src/app.php and register the namespace for the extension:</p>
<pre class="brush: php; title: ; notranslate">
 $app['autoloader']-&gt;registerNamespace('SilexExtension', __DIR__ . '/../vendor/silex-extension/src');
</pre>
<p>Then register the MongoDbExtension;</p>
<pre class="brush: php; title: ; notranslate">
 $app-&gt;register(new SilexExtension\MongoDbExtension(), array(
 'mongodb.class_path' =&gt; __DIR__ . '/../vendor/mongodb/lib',
 'mongodb.connection' =&gt; array(
 'server' =&gt; 'mongodb://mysecretuser:mysecretpassw@localhost',
 'options' =&gt; array(),
 'eventmanager' =&gt; function($eventmanager) {
 }
 )
 ));
</pre>
<p>and finally query your MongoDB collection of choice and display the resultset as json:</p>
<pre class="brush: php; title: ; notranslate">
$app-&gt;get('/data-from-mongodb', function() use($app) {

$coll = $app['mongodb']-&gt;selectDatabase('mydb')-&gt;selectCollection('mycoll');
 $query = array(
 'query' =&gt; 'value'
 );
 $sort = array(
 'count' =&gt; -1,
 );
 $r = $coll-&gt;find($query)-&gt;sort($sort)-&gt;toArray();
 $response = new Response();
 $response-&gt;headers-&gt;set('Content-type', 'application/json');
 $response-&gt;setContent(json_encode($r));
 return $response;
 });
</pre>
<p>Easy</p>
<div class="plus-one-wrap"><g:plusone href="http://nerdpress.org/2012/01/30/silex-and-mongodb-simply/"></g:plusone></div>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdpress.org/2012/01/30/silex-and-mongodb-simply/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>extend SilverStripe memberprofile module</title>
		<link>http://nerdpress.org/2012/01/16/extend-silverstripe-memberprofile-module/</link>
		<comments>http://nerdpress.org/2012/01/16/extend-silverstripe-memberprofile-module/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 09:50:42 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[Silverstripe]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=2021</guid>
		<description><![CDATA[Alright, SilverStripe again, still our CMS of choice. Today i&#8217;d like to promote a very helpful module that provides Register and Profile Pages for Members for the Frontend. The memberprofiles module. It comes with a lot of features and customize options for nearly everthing you might need for Frontend Member Handling. Further it is fully [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Alright, <a href="http://www.silverstripe.org/">SilverStripe</a> again, still our CMS of choice.<br />
Today i&#8217;d like to promote a very helpful module that provides Register and Profile Pages for Members for the Frontend.<br />
The <a href="https://github.com/ajshort/silverstripe-memberprofiles">memberprofiles module</a>.<br />
It comes with a lot of features and customize options for nearly everthing you might need for Frontend Member Handling.<br />
Further it is fully extendible to customize it even more.</p>
<p>For a starter tutorial i recommend a very <a href="http://deadlytechnology.com/silverstripe/membership-module/">good post</a> by deadlytechnology.<br />
I would like to describe how you extend it.</p>
<p>First lets install it (with the <em>orderable module</em> dependency):</p>
<p><span id="more-2021"></span></p>
<pre class="brush: bash; title: ; notranslate">
cd my_silverstripe_project
git clone https://github.com/ajshort/silverstripe-orderable.git
mv silverstripe-orderable/ orderable
git clone http://github.com/ajshort/silverstripe-memberprofiles.git
mv silverstripe-memberprofiles/ memberprofiles
</pre>
<p>Run <em>/dev/build?flush=all</em></p>
<p>At this point i like to skip the further setup, for this, go read the post recommended above.</p>
<p>So now lets extend f.e. the Register Page for the Member to provide a custom template for a custom member, say: Customer, and some additional logic.</p>
<p>Just make a new file <em>mysite/code/CustomerRegisterPage.php</em>:</p>
<pre class="brush: php; title: ; notranslate">
class CustomerRegisterPage extends MemberProfilePage {
 ...
}

class CustomerRegisterPage_Controller extends MemberProfilePage_Controller {
 ...
}
</pre>
<p>and a template: <em>themes/mytheme/CustomerRegisterPage.ss</em><br />
In this template you can now add your markup and include the MemberProfileForm via $RegisterForm.<br />
Or make your own Form by overwriting the RegisterForm in the Controller or make a complete new Form.</p>
<p>To register the template with the extended Page we have to overwrite the index method in the controller.</p>
<pre class="brush: php; title: ; notranslate">
public function index() {
        if (isset($_GET['BackURL'])) {
            Session::set('MemberProfile.REDIRECT', $_GET['BackURL']);
        }
        return $this-&gt;renderWith(array('CustomerRegisterPage', 'Page'));
}
</pre>
<p>Now we overwrite the register method to add some additional logic, f.e. to add a custom DataObject from a many_many relation from the customer Member.</p>
<pre class="brush: php; title: ; notranslate">
public function register($data, Form $form) {
        if ($member = $this-&gt;addMember($form)) {
            if (isset($data['OptionsID'])) {
                foreach ($data['OptionsID'] as $key =&gt; $value) {
                    $member-&gt;Options()-&gt;setByIDList($data['OptionsID']);
                }
            }
            return $this-&gt;redirect($this-&gt;Link('afterregistration'));
        } else {
            return $this-&gt;redirectBack();
        }
}
</pre>
<p>Thats it!<br />
Now create a new CustomerRegisterPage in the backend and do as you learned from deadlytechnology.</p>
<p><a href="http://nerdpress.org/wp-content/uploads/2012/01/silverstripe_memberprofiles.png" rel="lightbox[post-2021]" title=""><img class="alignnone size-medium wp-image-2023" src="http://nerdpress.org/wp-content/uploads/2012/01/silverstripe_memberprofiles-300x104.png" alt="Silverstripe Memberprofiles-300x104 in " width="300" height="104" /></a></p>
<div class="plus-one-wrap"><g:plusone href="http://nerdpress.org/2012/01/16/extend-silverstripe-memberprofile-module/"></g:plusone></div>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdpress.org/2012/01/16/extend-silverstripe-memberprofile-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>thank gawd it’s online #3</title>
		<link>http://nerdpress.org/2011/12/30/thank-gawd-it-s-online-3-2/</link>
		<comments>http://nerdpress.org/2011/12/30/thank-gawd-it-s-online-3-2/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 12:04:39 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[TGIO]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[resources]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=2010</guid>
		<description><![CDATA[A little making of history from duckduckgo search engine. http://www.gabrielweinberg.com/blog/2011/12/duckduckgo-used-to-run-out-of-my-basement.html LinkedIn node.js performance tricks http://engineering.linkedin.com/nodejs/blazing-fast-nodejs-10-performance-tips-linkedin-mobile introducing PHP&#8217;s composer http://nelm.io/blog/2011/12/composer-part-1-what-why/ promoting PHP&#8217;s composer http://nelm.io/blog/2011/12/composer-part-2-impact/ node.js and PHP http://bergie.iki.fi/blog/dnode-make_php_and_node-js_talk_to_each_other/ JavaScript API for zooming http://lab.hakim.se/zoom-js/ Gadget: little printer http://vimeo.com/32796535 jQuery Animations with automatic CSS3 transitions when possible http://playground.benbarnett.net/jquery-animate-enhanced/ Batman.js is a framework for building rich web applications with [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>A little making of history from duckduckgo search engine.<br />
<a href="http://www.gabrielweinberg.com/blog/2011/12/duckduckgo-used-to-run-out-of-my-basement.html">http://www.gabrielweinberg.com/blog/2011/12/duckduckgo-used-to-run-out-of-my-basement.html</a></p>
<p>LinkedIn node.js performance tricks<br />
<a href="http://engineering.linkedin.com/nodejs/blazing-fast-nodejs-10-performance-tips-linkedin-mobile">http://engineering.linkedin.com/nodejs/blazing-fast-nodejs-10-performance-tips-linkedin-mobile</a></p>
<p>introducing PHP&#8217;s composer<br />
<a href="http://nelm.io/blog/2011/12/composer-part-1-what-why/">http://nelm.io/blog/2011/12/composer-part-1-what-why/</a></p>
<p>promoting PHP&#8217;s composer<br />
<a href="http://nelm.io/blog/2011/12/composer-part-2-impact/">http://nelm.io/blog/2011/12/composer-part-2-impact/</a></p>
<p>node.js and PHP<br />
<a href="http://bergie.iki.fi/blog/dnode-make_php_and_node-js_talk_to_each_other/">http://bergie.iki.fi/blog/dnode-make_php_and_node-js_talk_to_each_other/</a></p>
<p>JavaScript API for zooming<br />
<a href="http://lab.hakim.se/zoom-js/">http://lab.hakim.se/zoom-js/</a></p>
<p>Gadget: little printer<br />
<a href="http://vimeo.com/32796535">http://vimeo.com/32796535</a></p>
<p>jQuery Animations with automatic CSS3 transitions when possible<br />
<a href="http://playground.benbarnett.net/jquery-animate-enhanced/">http://playground.benbarnett.net/jquery-animate-enhanced/</a></p>
<p>Batman.js is a framework for building rich web applications with CoffeeScript or JavaScript.<br />
<a href="http://batmanjs.org/">http://batmanjs.org/</a></p>
<p>some HTTP-Status Cats<br />
<a href="http://www.flickr.com/photos/girliemac/6508022985/in/set-72157628409467125">http://www.flickr.com/photos/girliemac/6508022985/in/set-72157628409467125</a></p>
<div class="plus-one-wrap"><g:plusone href="http://nerdpress.org/2011/12/30/thank-gawd-it-s-online-3-2/"></g:plusone></div>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdpress.org/2011/12/30/thank-gawd-it-s-online-3-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Expeditions in the Cloud</title>
		<link>http://nerdpress.org/2011/12/17/expeditions-in-the-cloud/</link>
		<comments>http://nerdpress.org/2011/12/17/expeditions-in-the-cloud/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 23:23:13 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[node.js]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cloud]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=1999</guid>
		<description><![CDATA[Caution: Scepticism ahead! So i&#8217;d like to share some of my experiences in the cloud since i am still trying to figure out if it its worth for me or if i am better suited with an VPS. Maybe somebody feels like feedbackin. I tried PHPFog for PHP and no.de by joyent for node.js. First i [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Caution: Scepticism ahead!</p>
<p>So i&#8217;d like to share some of my experiences in the cloud since i am still trying to figure out if it its worth for me or if i am better suited with an VPS.<br />
Maybe somebody feels like feedbackin.</p>
<p>I tried <a href="https://phpfog.com/">PHPFog</a> for PHP and<a href="https://no.de/"> no.de</a> by joyent for node.js.<br />
First i have to admit: yes i only tried the free models and of course they are limited and because its free you cant expect to get it all, right?<br />
Yes and thats true.</p>
<p>With PHPFog i set up an app based on symfony 1.4. After some inital problems due to some bugs on PHPFog side, i got it running.<br />
I really like to mention the kind and immediate chat support by PHPFog. It really made me feel like dealin with humans and not only machines. Big up!<br />
By then everything felt really smooth with git deploy, configurations, mysql setup etc.<br />
But i had to shut down the app again, because there are restrictions to PHP which killed the app like disabling &#8220;file_get_contents for remote URLS&#8221;, probably only in the free model. But that killed it for me at that point.<br />
So read this carefully before going to cloud: <a href="http://docs.phpfog.com/index.php/features/article/shared_vs_dedicated">http://docs.phpfog.com/index.php/features/article/shared_vs_dedicated</a><br />
I guess with dedicated hosting you get more power, sure.</p>
<p><span id="more-1999"></span>That brings me to the pricing plans, which means if you pay more you get more.<br />
That reminds me of good old shared hosting days.<br />
Of course in the cloud you get more and faster if you have to scale.<br />
Also if you have more apps you can bundle up, it can be a win, like read here: <a href="http://blog.phpfog.com/2011/12/08/but-isnt-php-fog-expensive-compared-to-vps/">http://blog.phpfog.com/2011/12/08/but-isnt-php-fog-expensive-compared-to-vps/</a><br />
Thats just fine, but if not you might be wrong there.<br />
And remember you are not in fully in control. So if you decide to checkout the Twig C extension: you cant.<br />
That also reminds me on good old shared hosting days.</p>
<p>With the node.js cloud i had similar deja vu&#8217;s:<br />
Gettin my node app running was not that easy but i made it after some approaches.<br />
Then it was cool: git deploy, npm support, console on the smartOS machine, having node on port 80, etc. That was great.</p>
<p><a href="http://nerdpress.org/wp-content/uploads/2011/12/no.de_.png" rel="lightbox[post-1999]" title=""><img class="alignnone size-medium wp-image-2001" src="http://nerdpress.org/wp-content/uploads/2011/12/no.de_-300x136.png" alt="No De -300x136 in " width="300" height="136" /></a><br />
But then i tried my app and had to realize sockets are not really working on Chrome and Firefox, wtf?<br />
It seemed that there was an issue with an node-http-proxy, as you can read here: <a href="http://discuss.joyent.com/viewtopic.php?id=30975">http://discuss.joyent.com/viewtopic.php?id=30975</a>.<br />
So that patch wasnt patched and all you could do is waiting, just like in good old shared hosting days.<br />
Get me?</p>
<p>So what am i trying to say?<br />
I am not really sure, but my resumee is if youre not building the next tumblr resp. you are not expecting high scaling you might improve your server skills and stick to an VPS.</p>
<p>What else? I am confused about the pricing!</p>
<p>With an VPS its clear, with Heroku and thelikes it could be 60$ per month or more, or less, or what?, I dont know.<br />
So its pretty much testing, see what your app is actually consuming and decide then.</p>
<p>And remember for PaaS Services as described you rely on the grace of the admins in the cloud.</p>
<div class="plus-one-wrap"><g:plusone href="http://nerdpress.org/2011/12/17/expeditions-in-the-cloud/"></g:plusone></div>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdpress.org/2011/12/17/expeditions-in-the-cloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silex and the HTTP_CACHE</title>
		<link>http://nerdpress.org/2011/11/29/silex-and-the-http-cache/</link>
		<comments>http://nerdpress.org/2011/11/29/silex-and-the-http-cache/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 09:52:11 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[Silex]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=1990</guid>
		<description><![CDATA[The HTTP_CACHE resp. the reverse proxy of Symfony is a pretty cool thing. And as it is build-in Silex it can speed up the already fast micro framework massivly, wich is good for me, as i am mainly workin with Silex right now. To enable it you have to register it first like its shown [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>The HTTP_CACHE resp. the reverse proxy of Symfony is a pretty cool thing.<br />
And as it is build-in <a href="http://silex.sensiolabs.org/">Silex</a> it can speed up the already fast micro framework massivly,<br />
wich is good for me, as i am mainly workin with Silex right now.</p>
<p>To enable it you have to register it first like its shown in the <a href="http://silex.sensiolabs.org/doc/providers/http_cache.html">docs</a>:</p>
<pre class="brush: php; title: ; notranslate">
 $app-&gt;register(new Silex\Provider\HttpCacheServiceProvider(), array(
 'http_cache.cache_dir' =&gt; __DIR__.'/cache/',
 ));
</pre>
<p>Also provide the writable cache dir.<br />
<span id="more-1990"></span></p>
<p>Then you have to return the Response Object with HTTP cache headers.</p>
<pre class="brush: php; title: ; notranslate">
$app-&gt;get('/about', function () use ($app) {
 $body = $app['twig']-&gt;render('about.twig');
 return new Response($body, 200, array('Cache-Control' =&gt; 's-maxage=3600, public'));
 });
</pre>
<p>And its good practice to finally call it with a dev switch.</p>
<pre class="brush: php; title: ; notranslate">
if ($app['debug']) {
 $app-&gt;run();
 }
 else{
 $app['http_cache']-&gt;run();
 }
</pre>
<p>Now in production environment the page will be cached and if it gets requested it will be served from the cache, if the cached version is not older then the time-to-live limit given in seconds by s-maxage.<br />
So here you avoid expensive calculation time.<br />
You could also provide a max-age directive to tell the client to cache it on clientside, to avoid the HTTP Request.<br />
But as always with caches its quite a rodeo to balance performance and up-to-dateness.<br />
Expiration and Validation Headers can of course be used aswell to controll the cache even more.</p>
<p>To illustrate the performance increase i loaded a simple about-page, which actually does nothing more then render a template.<br />
So while warming the cache it needed 606ms and from the cache it reduced to 190ms.<br />
warm cache:<br />
<a href="http://nerdpress.org/wp-content/uploads/2011/11/about_cache_warmer.png"> <img class="alignnone size-medium wp-image-1992" src="http://nerdpress.org/wp-content/uploads/2011/11/about_cache_warmer-300x16.png" alt="About Cache Warmer-300x16 in " width="300" height="16" /></a><br />
from cache:<a href="http://nerdpress.org/wp-content/uploads/2011/11/about_from_cache.png"><br />
<img class="alignnone size-medium wp-image-1993" src="http://nerdpress.org/wp-content/uploads/2011/11/about_from_cache-300x16.png" alt="About From Cache-300x16 in " width="300" height="16" /></a><br />
I cant tell how representative this is, but it aswell feels much faster, especially if you got more logic behind the page, like webservice calls etc.</p>
<p>BTW my <a href="https://github.com/ivoba/superleansilexplate">superleansilexplate</a> got also updated to support the Cache.</p>
<div class="plus-one-wrap"><g:plusone href="http://nerdpress.org/2011/11/29/silex-and-the-http-cache/"></g:plusone></div>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdpress.org/2011/11/29/silex-and-the-http-cache/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Enable Twig-Extensions in Silex</title>
		<link>http://nerdpress.org/2011/11/21/enable-twig-extensions-in-silex/</link>
		<comments>http://nerdpress.org/2011/11/21/enable-twig-extensions-in-silex/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 08:55:49 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Silex]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=1979</guid>
		<description><![CDATA[Note: its about Twig-extensions not about the former &#8220;Silex Twig Extension&#8221;, this now called TwigServiceProvider. First fetch the Twig-extensions code and put them in your vendor dir: Then register the autoloader by using registerPrefixes: You will need to register the TwigServiceProvider itself: And eventually enable the Extension you like to use, in my case the [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Note: its about <a href="https://github.com/fabpot/Twig-extensions">Twig-extensions</a> not about the former &#8220;Silex Twig Extension&#8221;, this now called TwigServiceProvider.</p>
<p>First fetch the Twig-extensions code and put them in your vendor dir:</p>
<pre class="brush: bash; title: ; notranslate">
git submodule add git://github.com/fabpot/Twig-extensions.git vendor/Twig-extensions/fabpot
git submodule init
git submodule update
</pre>
<p>Then register the autoloader by using registerPrefixes:</p>
<pre class="brush: php; title: ; notranslate">
$app['autoloader']-&gt;registerPrefixes(array(
    'Twig_Extensions_'  =&gt; array(__DIR__.'/../vendor/Twig-extensions/fabpot/lib')));
</pre>
<p><span id="more-1979"></span></p>
<p>You will need to register the TwigServiceProvider itself:</p>
<pre class="brush: php; title: ; notranslate">
$app-&gt;register(new Silex\Provider\TwigServiceProvider(), array(
    'twig.path' =&gt; __DIR__ . '/../views',
    'twig.class_path' =&gt; __DIR__ . '/../vendor/twig/lib',
));
</pre>
<p>And eventually enable the Extension you like to use, in my case the Text Extension to use the truncate filter:</p>
<pre class="brush: php; title: ; notranslate">
$oldTwigConfiguration = isset($app['twig.configure']) ? $app['twig.configure']: function(){};
$app['twig.configure'] = $app-&gt;protect(function($twig) use ($oldTwigConfiguration) {
    $oldTwigConfiguration($twig);
    $twig-&gt;addExtension(new Twig_Extensions_Extension_Text());
});
</pre>
<p>That might look a bit strange but it has its reasons, read <a href="https://github.com/fabpot/Silex/issues/160">here</a>.</p>
<p>Thats it! Now i can use something like this in my twig templates:</p>
<pre class="brush: plain; title: ; notranslate">
{{ post.content|raw|truncate(200) }}
</pre>
<div class="plus-one-wrap"><g:plusone href="http://nerdpress.org/2011/11/21/enable-twig-extensions-in-silex/"></g:plusone></div>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdpress.org/2011/11/21/enable-twig-extensions-in-silex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sending invalid Unicode via socket.io</title>
		<link>http://nerdpress.org/2011/11/16/sending-invalid-unicode-via-socket-io/</link>
		<comments>http://nerdpress.org/2011/11/16/sending-invalid-unicode-via-socket-io/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 14:48:54 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[socket.io]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=1971</guid>
		<description><![CDATA[Well you can try to, but it will end up almost probably in an disconnect which is caused by the browser. As i have learned here. Given you have a string which contains invalid unicode like: This will trouble the browser and the socket connection. If you prepare your json with PHP and  json_encode the [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Well you can try to, but it will end up almost probably in an disconnect which is caused by the browser.<br />
As i have learned <a href="https://github.com/LearnBoost/socket.io/issues/572">here</a>.</p>
<p>Given you have a string which contains invalid unicode like:</p>
<p><a href="http://nerdpress.org/wp-content/uploads/2011/11/invalid_unicode.png" rel="lightbox[post-1971]" title=""><img class="alignnone size-medium wp-image-1976" src="http://nerdpress.org/wp-content/uploads/2011/11/invalid_unicode-300x29.png" alt="Invalid Unicode-300x29 in " width="300" height="29" /></a><br />
This will trouble the browser and the socket connection.</p>
<p>If you prepare your json with PHP and  <em>json_encode</em> the Unicode will be escaped to some strings like these:</p>
<p><code>\ud83d\ude31\ud83d\ude31\ud83d\ude04\ud83d\ude04\ud83d\udc9c\ud83d\udc9c\ud83d\udc4a</code></p>
<p>But on clientside it will still result in invalid Unicode.<br />
<span id="more-1971"></span></p>
<p>So after a lot of recherche i found <a href="http://stackoverflow.com/questions/410704/cyrillic-characters-in-phps-json-encode">this</a> and used the <em>decodeUnicodeString</em> function from Zend to convert the escaped Unicode characters again to their unescaped representation. (dont forget the replacement as described in the post at stackoverflow if you extract it from Zend)<br />
If the character is invalid it will be replaced by a question mark &#8216;?&#8217;.<br />
This is at least what i asume.<br />
The ? went through fine and the socket connection stays alive.</p>
<p>Ok the downside is you loose weird signs for an &#8216;?&#8217;, but i can live with that.<br />
But im not really convinced with that solution, so if anybody knows another way to detect invalid Unicode sequences, let me know!</p>
<div class="plus-one-wrap"><g:plusone href="http://nerdpress.org/2011/11/16/sending-invalid-unicode-via-socket-io/"></g:plusone></div>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdpress.org/2011/11/16/sending-invalid-unicode-via-socket-io/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OXID eshop routing</title>
		<link>http://nerdpress.org/2011/11/14/oxid-eshop-routing/</link>
		<comments>http://nerdpress.org/2011/11/14/oxid-eshop-routing/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 10:53:05 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[OXID]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=1949</guid>
		<description><![CDATA[If you wonder about routing in OXID eshops or how the URL structure is here are some hints: OXIDs MVC, well thats some kind of different naming and you have to get used to: the M (Model) you find in /core the V you find in in your templates in /out, there the main view [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>If you wonder about routing in OXID eshops or how the URL structure is here are some hints:</p>
<p>OXIDs MVC, well thats some kind of different naming and you have to get used to:</p>
<p>the <strong>M</strong> (Model) you find in /core<br />
the <strong>V</strong> you find in in your templates in /out, there the main view is called the same as your controller, given the controller has a render() method.<br />
/views/details =&gt; /out/[templatename]/page/details.tpl<br />
the <strong>C</strong> (Controller) you find in /views (<em>what? oyerywell!</em>)<br />
like /views/details.php</p>
<p>The routing itself is like so:<br />
<span id="more-1949"></span></p>
<pre class="brush: plain; title: ; notranslate">?cl = controller</pre>
<p>in /views</p>
<pre class="brush: plain; title: ; notranslate">?anid = productID </pre>
<p>(that means the hash from the OXID field) or uid if you busy with users or any other relevant id</p>
<pre class="brush: plain; title: ; notranslate">?fnc = myfunction</pre>
<p>the method in the controller in /views</p>
<p>So this ends up in something like this:</p>
<pre class="brush: plain; title: ; notranslate">&lt;br /&gt;
theshop.de?cl=details&amp;amp;anid=05848170643ab0deb9914566391c0c63&amp;amp;fnc=myfunction&lt;br /&gt;
</pre>
<p>This is unmasked routing, normally OXID has this covered in SEO URLs with prettier slugs.</p>
<p>To use custom methods in the controller you have to extend it, the OXID module way, check this <a href="http://wiki.oxidforge.org/Tutorials#How_to_Extend_OXID_eShop_With_Modules_.28Part_1.29">here</a>.</p>
<p>Apropos OXID module way: actually its not so bad, i like the emulation of multiple overloading for the models and controllers.<br />
The module registry in the database however is something id rather have in the code, that would be easier to maintain over environments.<br />
Also some better cascading for templates, assets, lang files etc in the modules would be cool. That &#8220;<em>copy here copy there</em>&#8221; installations can be quite annoying.<br />
But anyway: i can deal with that.</p>
<div class="plus-one-wrap"><g:plusone href="http://nerdpress.org/2011/11/14/oxid-eshop-routing/"></g:plusone></div>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdpress.org/2011/11/14/oxid-eshop-routing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silex Starter Stubs</title>
		<link>http://nerdpress.org/2011/11/04/silex-starter-stubs/</link>
		<comments>http://nerdpress.org/2011/11/04/silex-starter-stubs/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 14:01:46 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Silex]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Ant]]></category>
		<category><![CDATA[h5bp]]></category>
		<category><![CDATA[silex]]></category>
		<category><![CDATA[skeleton]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=1924</guid>
		<description><![CDATA[There are several preconfigured Silex Apps on github. They let you start your Silex project in no time, which is good. This makes Silex an even more simple rabbithole into the symfony2 world. I started one myself and had a close look on the others, so i thought i share this. They all differ a [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>There are several preconfigured <a href="http://silex.sensiolabs.org/">Silex</a> Apps on github. They let you start your Silex project in no time, which is good.<br />
This makes Silex an even more simple rabbithole into the symfony2 world.</p>
<p>I started one myself and had a close look on the others, so i thought i share this.<br />
They all differ a bit so you must choose what fits your needs the best.</p>
<p>They all follow some kind of &#8220;best practise&#8221; structure, some more, some less.</p>
<p><span id="more-1924"></span></p>
<p>So there is: <a href="https://github.com/gcalore/Silex-Stub">https://github.com/gcalore/Silex-Stub</a><br />
This has several common Providers already enabled:</p>
<ul>
<li>Twig</li>
<li>UrlGenerator</li>
<li>Monolog</li>
<li>Doctrine DBAL</li>
<li>Validator</li>
<li>Forms</li>
</ul>
<p>but it has no Frontend Frameworks integrated.<br />
Another minus point is that the index is not in a web directory but in root, so that all lib files etc. are potentially accessible from the web, thou a .htaccess avoids that here.<br />
It also doesnt provide tests.<br />
So i wouldnt recommend that one.</p>
<p>The next one is: <a href="https://github.com/brtriver/silex-sample-application">https://github.com/brtriver/silex-sample-application</a><br />
This is a sample rudimentary blog application that you could use as starter.<br />
It has Doctrine and Twig build-in, it has tests but also doesnt include some frontend magic.</p>
<p>The most complete is: <a href="https://github.com/lyrixx/Silex-Kitchen-Edition">https://github.com/lyrixx/Silex-Kitchen-Edition</a><br />
This starterkit has several extension enabled:</p>
<ul>
<li>Doctrine</li>
<li>Form</li>
<li>Session</li>
<li>SymfonyBrige</li>
<li>Translation</li>
<li>Twig (with debug extension)</li>
<li>UrlGenerator</li>
</ul>
<p>and it also has the HTML5Boilerplate and Twitter`s Bootstrap integrated.<br />
Further <em>Assetic</em> and the <em>YAMLLoader</em> are already shipped and active and tests are provided aswell.<br />
Here Silex is included as submodule, which means unpacked &#8211; hence not as phar-, which might be interesting for some.<br />
In my Opinion this is some kind of a reference app, this is even more likely since the creator is sensio employee.<br />
I stole a lot from it ;).</p>
<p>Last but not least mine ;) : <a href="https://github.com/ivoba/superleansilexplate">https://github.com/ivoba/superleansilexplate</a><br />
Its supposed to be very lean.<br />
It comes just with <em>Twig</em> and <em>Translation</em> enabled.<br />
It aims mainly at simple applications that need routing and just some additional logic. F.e. its a good container for javascript driven apps that get their data through API calls. If you need database support and more, simply register the provider yourself or use the <a href="https://github.com/lyrixx/Silex-Kitchen-Edition">kitchen</a>.</p>
<p>Tests are included and for the frontend there is the a mix of skeleton(bootstrap seemed too verbose and too twitter branded for mi gusto) and HTML5boilerplate.<br />
Also there is an optimized Boilerplate Build included to avoid Assetic.</p>
<p><a href="http://nerdpress.org/wp-content/uploads/2011/11/superleansilexplate.png" rel="lightbox[post-1924]" title=""><img class="alignnone size-medium wp-image-1939" src="http://nerdpress.org/wp-content/uploads/2011/11/superleansilexplate-300x148.png" alt="Superleansilexplate-300x148 in " width="300" height="148" /></a><br />
Its not really finished yet, but sufficient to start with.<br />
(feel free to provide some improvements)</p>
<div class="plus-one-wrap"><g:plusone href="http://nerdpress.org/2011/11/04/silex-starter-stubs/"></g:plusone></div>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdpress.org/2011/11/04/silex-starter-stubs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>tell redis db to not persist</title>
		<link>http://nerdpress.org/2011/10/27/tell-redis-db-to-not-persist/</link>
		<comments>http://nerdpress.org/2011/10/27/tell-redis-db-to-not-persist/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 15:22:30 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[redis]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=1915</guid>
		<description><![CDATA[redis persists its memory data in snapshot style in every n seconds depending on your configuration. read more here. perhaps you would like to use redis as a pure in-memory db, like f.e. memchache. you can tell redis to not persist and save some bits&#38;miliseconds. this could be the case when using redis as a [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p><a href="http://redis.io">redis</a> persists its memory data in snapshot style in every <em>n</em> seconds depending on your configuration.<br />
read more <a href="http://redis.io/topics/persistence">here</a>.<br />
perhaps you would like to use redis as a pure in-memory db, like f.e. memchache.<br />
you can tell redis to not persist and save some bits&amp;miliseconds.<br />
this could be the case when using redis as a f.e. realtime queue, you wont need persistence,<br />
because you could say: nobody needs is newsfeed from the that day before the machine crashed ;)</p>
<p>alright, do so by:<br />
<span id="more-1915"></span></p>
<p>open:<br />
/etc/redis/redis.conf</p>
<p>you will find:</p>
<pre class="brush: bash; title: ; notranslate">
#   Note: you can disable saving at all commenting all the &quot;save&quot; lines.

save 900 1
save 300 10
save 60 10000
</pre>
<p>do as you are told:</p>
<pre class="brush: bash; title: ; notranslate">
#save 900 1
#save 300 10
#save 60 10000
</pre>
<p>&#8230;and save.<br />
then restart redis.</p>
<pre class="brush: bash; title: ; notranslate">
sudo /etc/init.d/redis-server restart
</pre>
<p>Doing!</p>
<div class="plus-one-wrap"><g:plusone href="http://nerdpress.org/2011/10/27/tell-redis-db-to-not-persist/"></g:plusone></div>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdpress.org/2011/10/27/tell-redis-db-to-not-persist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

