<?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>Max Girkens | Nerdpress.org</title>
	<atom:link href="https://nerdpress.org/author/max-girkens/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerdpress.org</link>
	<description>...dev, tech problems and solutions.</description>
	<lastBuildDate>Wed, 31 Mar 2021 05:43:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>EU/VAT &#8211; Mehrwertsteuer Madness</title>
		<link>https://nerdpress.org/2021/03/30/eu-vat-mehrwertsteuer-monkey-madness/</link>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Tue, 30 Mar 2021 19:13:57 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[tools]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2995</guid>

					<description><![CDATA[<p>Calculating European VAT Rates with PHP &#8211; the easy way. Disclaimer: No legal advice, just a little experience report. If you sell digital things (services, digital goods etc.) to EU countries, you might have to calculate the VAT at the rate of the customer&#8217;s country (and even pay it there afterwards).The latter is even the &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2021/03/30/eu-vat-mehrwertsteuer-monkey-madness/" class="more-link">Continue reading<span class="screen-reader-text"> "EU/VAT &#8211; Mehrwertsteuer Madness"</span></a></p>
The post <a href="https://nerdpress.org/2021/03/30/eu-vat-mehrwertsteuer-monkey-madness/">EU/VAT – Mehrwertsteuer Madness</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<h2 class="wp-block-heading">Calculating European VAT Rates with PHP &#8211; the easy way.</h2>



<p><strong>Disclaimer: No legal advice, just a little experience report.</strong></p>



<p>If you sell digital <em>things</em> (services, digital goods etc.) to EU countries, you might have to calculate the VAT at the rate of the customer&#8217;s country (and even pay it there afterwards).<br />The latter is even the more inconvenient part, but at least the first part can be done quite easily with good old PHP.</p>



<span id="more-2995"></span>



<p>Originally released as a Laravel plugin (or whatever it&#8217;s called in their bubble..), there is this very handy library that does the whole complex calculation starting from the seller&#8217;s country:</p>



<p><a href="https://github.com/driesvints/vat-calculator">https://github.com/driesvints/vat-calculator</a></p>



<p>Even more interesting for my purposes was this fork here:</p>



<p><a href="https://github.com/spaze/vat-calculator/">https://github.com/spaze/vat-calculator/</a></p>



<p>Works on the one hand as a complete standalone version, and still includes updates and is actually also rather a further development than a fork :thuink:<br />With this then the VAT can be calculated in a few easy calls and life is exceptionally easy.<br />Not only the country of the customer is taken into account, but also the postal code, because in Germany alone there are several different VAT rates, depending on the <a href="https://de.wikipedia.org/wiki/Helgoland" title="https://de.wikipedia.org/wiki/Helgoland">island</a> you happen to find yourself on.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
// Easy to use!
use Spaze\VatCalculator\VatCalculator;

$vatRates = new VatRates();
$vatCalculator = new VatCalculator($vatRates);
$vatCalculator-&gt;calculate(71.00, &#039;DE&#039; /* $countryCode */, &#039;41352&#039; /* $postalCode or null */,  true /* Whether the customer you&#039;re calculating the VAT for is a company */);
$vatCalculator-&gt;getTaxRateForLocation(&#039;NL&#039;);
// Check validity of a VAT number
$vatCalculator-&gt;isValidVatNumber(&#039;NL123456789B01&#039;);
</pre></div>


<p>With the appropriate VAT identification number, the annoyance of the collection is then also accordingly omitted.</p>



<p>So nice one, definitely saved me a lot of worries. Github-starred &#8211; Cheers guys!</p>The post <a href="https://nerdpress.org/2021/03/30/eu-vat-mehrwertsteuer-monkey-madness/">EU/VAT – Mehrwertsteuer Madness</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Symfony Workflow Component: Dump workflows as PDF</title>
		<link>https://nerdpress.org/2017/11/07/symfony-workflow-component-dump-workflows-pdf/</link>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Tue, 07 Nov 2017 05:10:59 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[graphviz]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[workflow]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2787</guid>

					<description><![CDATA[<p>One very cool feature of the Symfony Workflow Component is the ability to export workflows via graphviz. Did you know you can also directly render those as PDF files? It&#8217;s actually quite easy. Like so:</p>
The post <a href="https://nerdpress.org/2017/11/07/symfony-workflow-component-dump-workflows-pdf/">Symfony Workflow Component: Dump workflows as PDF</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>One very cool feature of the Symfony Workflow Component is the ability to export workflows via graphviz.</p>
<p>Did you know you can also directly render those as PDF files?<br />
<span id="more-2787"></span></p>
<p>It&#8217;s actually quite easy. Like so:</p>
<pre class="brush: bash; title: ; notranslate">
php bin/console workflow:dump myWorkflow | dot -Tpdf &gt; data/workflow/myWorkflow.pdf
</pre>The post <a href="https://nerdpress.org/2017/11/07/symfony-workflow-component-dump-workflows-pdf/">Symfony Workflow Component: Dump workflows as PDF</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Splitting Swagger API Documentation yaml files</title>
		<link>https://nerdpress.org/2017/10/01/splitting-swagger-api-documentation-yaml-files/</link>
					<comments>https://nerdpress.org/2017/10/01/splitting-swagger-api-documentation-yaml-files/#comments</comments>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Sun, 01 Oct 2017 06:00:22 +0000</pubDate>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[swagger]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2777</guid>

					<description><![CDATA[<p>When documenting your API with Swagger/Swagger-UI, one really cool feature to use is the $ref syntax. As Swagger documentation files tend to get real large und hard too read, splitting the config across multiple files might be a good idea. With $ref you could do this quite easily. For example you could reference a single &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2017/10/01/splitting-swagger-api-documentation-yaml-files/" class="more-link">Continue reading<span class="screen-reader-text"> "Splitting Swagger API Documentation yaml files"</span></a></p>
The post <a href="https://nerdpress.org/2017/10/01/splitting-swagger-api-documentation-yaml-files/">Splitting Swagger API Documentation yaml files</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>When documenting your API with <a href="https://swagger.io/swagger-ui/">Swagger/Swagger-UI</a>, one really cool feature to use is the <em>$ref</em> syntax.</p>
<p>As Swagger documentation files tend to get real large und hard too read, splitting the config across multiple files might be a good idea.<br />
With <em>$ref</em> you could do this quite easily.<br />
<span id="more-2777"></span><br />
For example you could reference a single config file per path like so:</p>
<pre class="brush: yaml; title: ; notranslate">
swagger: &quot;2.0&quot;
basePath: &quot;my-api/v1/&quot;
info:
  version: &quot;0.0.1&quot;
  title: &quot;my API&quot;
tags:
  - name: &quot;section1&quot;
    description: &quot;Some Section&quot;
  - name: &quot;section2&quot;
    description: &quot;Some other Section&quot;

paths:

  ##section 1

  /section1/some/path:
    $ref: 'paths/section1_some_path.yml'

  /section1/some-other-path:
    $ref: 'paths/section1_some_other_path.yml'
</pre>
<p>Then have all actions for this path defined in a dedicated file like this:</p>
<p><strong>paths/section1_some_path.yml:</strong></p>
<pre class="brush: yaml; title: ; notranslate">
post:
  tags:
  - &quot;section1&quot;
  parameters:
    ...
</pre>
<p>This really helped me managing larger documentation files, which otherwise tend to get quite hard to read.</p>The post <a href="https://nerdpress.org/2017/10/01/splitting-swagger-api-documentation-yaml-files/">Splitting Swagger API Documentation yaml files</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
					<wfw:commentRss>https://nerdpress.org/2017/10/01/splitting-swagger-api-documentation-yaml-files/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Symfony and Angular: shared translations</title>
		<link>https://nerdpress.org/2017/09/04/symfony-and-angular-shared-translations/</link>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Mon, 04 Sep 2017 15:21:51 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Project Setup]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Angular.js]]></category>
		<category><![CDATA[i18n]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2742</guid>

					<description><![CDATA[<p>Angular for frontend with symfony delivering the data have become quite a common setup. When working with this constellation you will sooner or later come across the i18n topic. Most likely you would want to share translations between front- and backend. So that you could keep translations in one single location while using it for &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2017/09/04/symfony-and-angular-shared-translations/" class="more-link">Continue reading<span class="screen-reader-text"> "Symfony and Angular: shared translations"</span></a></p>
The post <a href="https://nerdpress.org/2017/09/04/symfony-and-angular-shared-translations/">Symfony and Angular: shared translations</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p><a href="https://angularjs.org/">Angular</a> for frontend with <a href="http://symfony.com/">symfony</a> delivering the data have become quite a common setup.</p>
<p>When working with this constellation you will sooner or later come across the i18n topic. Most likely you would want to share translations between front- and backend. So that you could keep translations in one single location while using it for frontend templates as well as server-side error messages etc.</p>
<p>One <a href="https://stackoverflow.com/questions/19686291/translations-shared-between-symfony2-and-angular-js">approach</a> would be to store translations in the symfony yml or xml files and deliver those to the frontend via an api endpoint.<br />
Given that front- and backend-code run <strong>on the same server</strong>, there is an even simpler solution.<br />
<span id="more-2742"></span></p>
<p>Since symfony does not only read <a href="https://symfony.com/doc/current/components/translation.html#loading-message-catalogs">yml or xml</a> but also translations in the <a href="https://symfony.com/doc/current/components/translation.html#loading-message-catalogs">json format</a>, you can simply keep translations in the frontend and read those files with symfony directly.</p>
<p>All you need to do to achieve this is <a href="https://en.wikipedia.org/wiki/Symbolic_link">symlink</a> the angular translation files to your symfony translation catalog location. </p>
<pre class="brush: bash; title: ; notranslate">
messages.de.json -&gt; ../../../web/ng/I18n/de_DE.json
messages.en.json -&gt; ../../../web/ng/I18n/en_EN.json
</pre>
<p><em>Disclaimer: This works only for relatively simple use cases with no complex translation patterns. But hey&#8230;</em></p>The post <a href="https://nerdpress.org/2017/09/04/symfony-and-angular-shared-translations/">Symfony and Angular: shared translations</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Symfony development with docker on a mac</title>
		<link>https://nerdpress.org/2016/05/07/symfony-development-docker-mac/</link>
					<comments>https://nerdpress.org/2016/05/07/symfony-development-docker-mac/#comments</comments>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Sat, 07 May 2016 18:04:52 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Project Setup]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[mac]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2681</guid>

					<description><![CDATA[<p>I recently started to do all PHP development with docker, since I was just tired of installing tons of dev libraries on my machine. Most of which i couldn&#8217;t even remember what they actually were good for. When I first tried docker (docker-toolbox for mac) I was really disappointed how slow symfony apps ran inside &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2016/05/07/symfony-development-docker-mac/" class="more-link">Continue reading<span class="screen-reader-text"> "Symfony development with docker on a mac"</span></a></p>
The post <a href="https://nerdpress.org/2016/05/07/symfony-development-docker-mac/">Symfony development with docker on a mac</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>I recently started to do all PHP development with docker, since I was just tired of installing tons of dev libraries on my machine. Most of which i couldn&#8217;t even remember what they actually were good for.</p>
<p>When I first tried docker (docker-toolbox for mac) I was really disappointed how slow symfony apps ran inside the container.<span id="more-2681"></span></p>
<p>I did a bit of research (didn&#8217;t completely get it though)  &#8211; but most of the speed issues that people experience seem to be related to the rather slow file system access in mounted folders.</p>
<p>That&#8217;s where <a href="https://github.com/nlf/dlite">dlite</a> really shines.<br />
It&#8217;s an app that uses <a href="https://github.com/nlf/dlite#thanks">some sort of alternative</a> to virtualbox etc. which has significant speed advantages.</p>
<p>I highly recommend you give it a try if you&#8217;re developing with docker in OSX.<br />
Installation with <a href="http://brew.sh/">homebrew</a> is quite simple:</p>
<pre class="brush: bash; title: ; notranslate">
brew install dlite
dlite stop &amp;&amp; dlite update -v 2.3.0 &amp;&amp; dlite start
brew install docker
brew install docker-compose
</pre>
<p>Another thing I found quite challenging was setting up permissions when running symfony inside docker.<br />
I found a couple of tutorials on that but none of those seemed to really work with my setup.</p>
<p>You could use data containers for the cache and log folders and don&#8217;t have any <a href="http://stackoverflow.com/questions/34949083/symfony-docker-permission-problems-for-cache-files">permission problems</a>.<br />
Or just use some internal folder `/tmp/myapp/cache` or `/dev/shm/myapp` (the latter really is fast&#8230;).</p>
<p>But any of those approaches will make it difficult to access the cache files from the host.<br />
(I use PHPStorm with the symfony plugin, which relies on parsing some cache files)<br />
It also doesn&#8217;t solve the problem of persmissions for the `/web` folders, when installing assets or write to any data folders you also wan&#8217;t to mount from the host filesystem.</p>
<p>I have not found a really elegant solution for that, but there&#8217;s a workaround which does work magic:</p>
<p>You can set uid of the www-data inside the container your host users&#8217; uid.<br />
Something like `RUN usermod -u 501 www-data` inside your webserver Dockerfile should do the trick for your default user on mac. You can then log into the container and run symfony commands as www-data and have no problems with accessing files from host filesystem, command-line or the webserver.</p>
<p><a href="https://nerdpress.org">W</a><a href="https://www.facebook.com/sonntagnacht">e</a> put together a docker setup for symfony development, which should work across different operating systems.</p>
<p><a href="https://github.com/nerdpress-org/docker-sf3/">https://github.com/nerdpress-org/docker-sf3/</a></p>
<p>So as a quickstart, after installing docker &#038; dlite just run:</p>
<pre class="brush: bash; title: ; notranslate">
git clone https://github.com/nerdpress-org/docker-sf3.git docker-sf3
cp -r docker-sf3/docker /path/to/your/symfony-project/
cd /path/to/your/symfony-project/docker
sh ./docker.sh -l
</pre>The post <a href="https://nerdpress.org/2016/05/07/symfony-development-docker-mac/">Symfony development with docker on a mac</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
					<wfw:commentRss>https://nerdpress.org/2016/05/07/symfony-development-docker-mac/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>RegExpBuilderPHP &#8211; PHP Regular Expression Builder</title>
		<link>https://nerdpress.org/2015/02/13/regexpbuilderphp-php-regular-expression-builder/</link>
					<comments>https://nerdpress.org/2015/02/13/regexpbuilderphp-php-regular-expression-builder/#comments</comments>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Fri, 13 Feb 2015 14:38:45 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Weekend Projects]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2625</guid>

					<description><![CDATA[<p>There this really useful tool for JS, called RegExpBuilder. It enables you to build regular expressions with a nice human-readable &#038; chainable syntax. (read more about it here and here) As it&#8217;s not that much lines of code, I decided to do a port for PHP &#8211; et voila: https://github.com/gherkins/regexpbuilderphp This is basically regex with &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2015/02/13/regexpbuilderphp-php-regular-expression-builder/" class="more-link">Continue reading<span class="screen-reader-text"> "RegExpBuilderPHP &#8211; PHP Regular Expression Builder"</span></a></p>
The post <a href="https://nerdpress.org/2015/02/13/regexpbuilderphp-php-regular-expression-builder/">RegExpBuilderPHP – PHP Regular Expression Builder</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>There this really useful tool for JS, called <a href="https://github.com/thebinarysearchtree/regexpbuilderjs/">RegExpBuilder</a>.<br />
It enables you to build regular expressions with a nice human-readable &#038; chainable syntax.<br />
(read more about it <a href="http://thebinarysearchtree.blogspot.de/2012/06/regexpbuilder.html">here</a> and <a href="https://github.com/thebinarysearchtree/regexpbuilderjs/wiki">here</a>)</p>
<p>As it&#8217;s not that much lines of code, I decided to do a port for PHP &#8211; et voila:</p>
<p><a href="https://github.com/gherkins/regexpbuilderphp">https://github.com/gherkins/regexpbuilderphp</a><br />
<span id="more-2625"></span></p>
<p>This is basically regex with PHP the easy way:</p>
<p>Say you want to validate some currency string like &#8220;€ 105,99&#8221; but want &#8220;€ 12.000,95&#8221; to be also valid.<br />
Coming up with a regex for that i would find challenging, to say the least.</p>
<p>PHP RegExpBuilder to the rescue:</p>
<p>(you can simply install it via composer)</p>
<pre class="brush: bash; title: ; notranslate">composer require gherkins/regexpbuilderphp:dev-master</pre>
<p>Then you&#8217;ll be able to do:</p>
<pre class="brush: php; title: ; notranslate">
$builder = new \Gherkins\RegExpBuilderPHP\RegExpBuilder();


    $builder1 = $builder
        -&gt;find(&quot;€&quot;)
        -&gt;exactly(1)-&gt;whitespace()
        -&gt;min(1)-&gt;digits()
        -&gt;then(&quot;,&quot;)
        -&gt;digit()
        -&gt;digit();
        
    //builder 1 will take care of the cases without a thousand-seperator

    $builder1-&gt;getRegExp()-&gt;test(&quot;€ 128,99&quot;);     //true
    $builder1-&gt;getRegExp()-&gt;test(&quot;€ 81,99&quot;);      //true
        
       
                     
    $builder2 = $builder-&gt;getNew()
        -&gt;find(&quot;€&quot;)
        -&gt;exactly(1)-&gt;whitespace()
        -&gt;min(1)-&gt;digits()
        -&gt;then(&quot;.&quot;)
        -&gt;exactly(3)-&gt;digits()
        -&gt;then(&quot;,&quot;)
        -&gt;digit()
        -&gt;digit();
        
    //builder 1 will take care of the cases *with* the thousand-seperator

    $builder2-&gt;getRegExp()-&gt;test(&quot;€ 1.228,99&quot;);   //true
    $builder2-&gt;getRegExp()-&gt;test(&quot;€ 452.000,99&quot;); //true
        
        
    //you can then combine both builders to get a regex which handles all cases:
       
    $combined = $this-&gt;r-&gt;getNew()
        -&gt;either($builder1)
        -&gt;orLike($builder2);
        
    $combined-&gt;getRegExp()-&gt;test(&quot;€ 128,99&quot;);     //true
    $combined-&gt;getRegExp()-&gt;test(&quot;€ 81,99&quot;);      //true
    $combined-&gt;getRegExp()-&gt;test(&quot;€ 1.228,99&quot;);   //true
    $combined-&gt;getRegExp()-&gt;test(&quot;€ 452.000,99&quot;); //true
</pre>
<p>This might be a bit verbose if you don&#8217;t have any problem with:</p>
<pre class="brush: bash; title: ; notranslate">
(?:(?:(?:(?:€){1,1})(?:(?:\s){1,1})(?:(?:(?:\d)){1,})(?:(?:,){1,1})(?:\d)(?:\d))|(?:(?:(?:€){1,1})(?:(?:\s){1,1})(?:(?:(?:\d)){1,})(?:(?:\.){1,1})(?:(?:(?:\d)){3,3})(?:(?:,){1,1})(?:\d)(?:\d)))
</pre>
<p>..but I really do like it ;)</p>
<p><a href="https://github.com/gherkins/regexpbuilderphp">https://github.com/gherkins/regexpbuilderphp</a></p>The post <a href="https://nerdpress.org/2015/02/13/regexpbuilderphp-php-regular-expression-builder/">RegExpBuilderPHP – PHP Regular Expression Builder</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
					<wfw:commentRss>https://nerdpress.org/2015/02/13/regexpbuilderphp-php-regular-expression-builder/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Symfony2 &#8220;urlize&#8221;</title>
		<link>https://nerdpress.org/2014/12/01/symfony2-urlize/</link>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Mon, 01 Dec 2014 09:11:17 +0000</pubDate>
				<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Symfony]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2583</guid>

					<description><![CDATA[<p>I have often missed the Doctrine_Inflector::urlize()  method from Doctrine1 in Symfony2 with Doctrine2. Of course there&#8217;s the doctrine extensions with the sluggable behaviour, but sometimes it seems a bit overhead for smaller tasks. I just recently discovered Behat Transliterator, which brings just the dearly missed urlize function back. Just do composer require behat/transliterator As it&#8217;s an abstract class, you&#8217;ll &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2014/12/01/symfony2-urlize/" class="more-link">Continue reading<span class="screen-reader-text"> "Symfony2 &#8220;urlize&#8221;"</span></a></p>
The post <a href="https://nerdpress.org/2014/12/01/symfony2-urlize/">Symfony2 “urlize”</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>I have often <a href="http://stackoverflow.com/questions/17467910/urlize-in-doctrine-inflector-class-in-doctrine-2-symfony-2">missed</a> the </p>
<pre class="brush: php; title: ; notranslate">Doctrine_Inflector::urlize()</pre>
<p> method from Doctrine1 in Symfony2 with Doctrine2.</p>
<p>Of course there&#8217;s the doctrine extensions with the <a href="https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/sluggable.md">sluggable behaviour</a>, but sometimes it seems a bit overhead for smaller tasks.</p>
<p>I just recently discovered <a href="https://github.com/Behat/Transliterator">Behat Transliterator</a>, which brings just the dearly missed urlize function back.</p>
<p><span id="more-2583"></span>Just do </p>
<pre class="brush: bash; title: ; notranslate">composer require behat/transliterator</pre>
<p>As it&#8217;s an abstract class, you&#8217;ll have to create your own Helper class extending it.</p>
<p>And there you go: </p>
<pre class="brush: php; title: ; notranslate">MyTextHelper::urlize(&quot;how great is that?&quot;)</pre>The post <a href="https://nerdpress.org/2014/12/01/symfony2-urlize/">Symfony2 “urlize”</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Using Silverstripe Templates outside Silverstripe</title>
		<link>https://nerdpress.org/2013/11/15/silverstripe-templates-outside-silverstripe/</link>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Fri, 15 Nov 2013 08:21:21 +0000</pubDate>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Silverstripe]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2462</guid>

					<description><![CDATA[<p>In a recent website-project i had a WordPress Blog running next to the main CMS Silverstripe, handling the Blog-part of the site. Integrating the Blog in Silverstripe (which indeed would have made things simpler) was not  an option at the time. The usage of loads of WordPress plugins would&#8217;ve made a rewrite a major task, which &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2013/11/15/silverstripe-templates-outside-silverstripe/" class="more-link">Continue reading<span class="screen-reader-text"> "Using Silverstripe Templates outside Silverstripe"</span></a></p>
The post <a href="https://nerdpress.org/2013/11/15/silverstripe-templates-outside-silverstripe/">Using Silverstripe Templates outside Silverstripe</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>In a recent website-project i had a <a href="http://wordpress.org/">WordPress</a> Blog running next to the main CMS <a href="http://www.silverstripe.org/">Silverstripe</a>, handling the Blog-part of the site.</p>
<p><em>Integrating the Blog in Silverstripe (which indeed would have made things simpler) was not  an option at the time. The usage of loads of WordPress plugins would&#8217;ve made a rewrite a major task, which was out of the budget.</em></p>
<p>The blog was integrated in the same page layout as the rest of the website. So ideally it would at least share the same Templates for header, footer etc. and would integrate the sites navigation built by Silverstripe.</p>
<p><strong>But how to use the pre-rendered <a href="http://doc.silverstripe.org/framework/en/3.0/reference/templates">Silverstripe template</a> <code>.ss</code> files in a WordPress theme?<br />
</strong></p>
<p>The following worked fine for me, using Silverstripe 3.0:<br />
<span id="more-2462"></span><br />
In the functions.php of the wordpress theme i added this code to init a silverstripe controller:</p>
<pre class="brush: php; title: ; notranslate">
//init silverstripe
require_once '&#x5B;path-to-silverstripe-root-folder]/framework/core/Core.php';
require_once '&#x5B;path-to-silverstripe-root-folder]/framework/model/DB.php';
//init the Database connection
DB::connect($databaseConfig);
//fetch some page, it that case i used the 404 ErrorPage
$SSPage = DataObject::get_by_id('Page', 4);
//init a the controller and cache it as a global variable
$SSctrl = new ContentController($SSPage);
//add the controller to the stack, so it becomes available as the current controller for the template
$SSctrl-&gt;pushCurrent();

</pre>
<p>and also some helper functions to get the actual templates</p>
<pre class="brush: php; title: ; notranslate">
function get_Silverstripe_Header()
{
    global $SSctrl;
    //render the controller with the includes/Header.ss template
    return $SSctrl-&gt;renderWith('Header');
}

function get_Silverstripe_Footer()
{
    global $SSctrl;
    //..or any other template, like the footer
    return $SSctrl-&gt;renderWith('Footer');
}
</pre>
<p>&#8230;and then just use these in the templates:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php echo get_Silverstripe_Header() ?&gt;
</pre>
<p>Of course this is no way limited to WordPress. It just an idea how<em> to access Silverstripe Templates outside of Silverstripe code</em>.</p>The post <a href="https://nerdpress.org/2013/11/15/silverstripe-templates-outside-silverstripe/">Using Silverstripe Templates outside Silverstripe</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>more Silverstripe bookmarklets</title>
		<link>https://nerdpress.org/2013/05/31/more-silverstripe-bookmarklets/</link>
					<comments>https://nerdpress.org/2013/05/31/more-silverstripe-bookmarklets/#comments</comments>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Fri, 31 May 2013 10:56:50 +0000</pubDate>
				<category><![CDATA[Silverstripe]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2443</guid>

					<description><![CDATA[<p>Since the Silverstripe-Developer Bookmarklets on ssbits.com are great, i thought it would be even better to have them as a editable/extendable collection: So here are some more as a JSFiddle: http://jsfiddle.net/HMkad/2/embedded/result/ If you&#8217;d like to extend the collection just edit the markup in the fiddle. And add something like this: &#60;li&#62; &#60;p&#62; &#60;strong&#62;?showqueries=1&#60;/strong&#62; - List all &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2013/05/31/more-silverstripe-bookmarklets/" class="more-link">Continue reading<span class="screen-reader-text"> "more Silverstripe bookmarklets"</span></a></p>
The post <a href="https://nerdpress.org/2013/05/31/more-silverstripe-bookmarklets/">more Silverstripe bookmarklets</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>Since the Silverstripe-Developer Bookmarklets <a href="http://www.ssbits.com/snippets/2012/silverstripe-developer-bookmarklets/">on ssbits.com</a> are great,<br />
i thought it would be even better to have them as a editable/extendable collection:</p>
<p>So here are some more as a JSFiddle:</p>
<p><a href="http://jsfiddle.net/HMkad/2/embedded/result/">http://jsfiddle.net/HMkad/2/embedded/result/<span id="more-2443"></span></a></p>
<p>If you&#8217;d like to extend the collection just edit the markup <a href="http://jsfiddle.net/HMkad/2/light/">in the fiddle</a>.<br />
And add something like this:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;li&gt;
  &lt;p&gt;
    &lt;strong&gt;?showqueries=1&lt;/strong&gt; - List all SQL queries executed
  &lt;/p&gt;
  &lt;a data-param=&quot;showqueries=1&quot; href=&quot;#&quot;&gt;
    SS:showqueries=1
  &lt;/a&gt;
&lt;/li&gt;
</pre>
<p>&#8230;or this:</p>
<pre class="brush: xml; title: ; notranslate">
 &lt;li&gt;
   &lt;p&gt;
    &lt;strong&gt;dev/build&lt;/strong&gt; - Rebuild the entire database and manifest
   &lt;/p&gt;
   &lt;a data-param=&quot;dev/build&quot; href=&quot;#&quot;&gt;
     SS:dev/build
   &lt;/a&gt;
&lt;/li&gt;
</pre>
<p>Have fun!</p>The post <a href="https://nerdpress.org/2013/05/31/more-silverstripe-bookmarklets/">more Silverstripe bookmarklets</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
					<wfw:commentRss>https://nerdpress.org/2013/05/31/more-silverstripe-bookmarklets/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>JSfiddle Bookmarklet Generator with jQuery &#038; Codemirror</title>
		<link>https://nerdpress.org/2013/03/08/jsfiddle-bookmarklet-generator-with-jquery-codemirror/</link>
					<comments>https://nerdpress.org/2013/03/08/jsfiddle-bookmarklet-generator-with-jquery-codemirror/#comments</comments>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Fri, 08 Mar 2013 11:41:59 +0000</pubDate>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[CodeMirror]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jsfiddle]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2410</guid>

					<description><![CDATA[<p>This is a little bookmarklet generator i put together this morning: http://jsfiddle.net/QMeuV/1/embedded/result/ Its hosted on jsfiddle.net and enables you to create Bookmarklets which use jQuery based on the code i found here: http://coding.smashingmagazine.com/2010/05/23/make-your-own-bookmarklets-with-jquery/ It also features Javascript Syntax Highlighting using http://codemirror.net/. *UPDATE* this tool now (also) lives on https://github.com/gherkins/bookmarklet-generator</p>
The post <a href="https://nerdpress.org/2013/03/08/jsfiddle-bookmarklet-generator-with-jquery-codemirror/">JSfiddle Bookmarklet Generator with jQuery & Codemirror</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>This is a little bookmarklet generator i put together this morning:</p>
<p><a href="http://jsfiddle.net/QMeuV/1/embedded/result/">http://jsfiddle.net/QMeuV/1/embedded/result/<span id="more-2410"></span></a></p>
<p><a href="https://nerdpress.org/wp-content/uploads/2013/03/Bildschirmfoto-2013-03-08-um-12.24.55.png"><img fetchpriority="high" decoding="async" class="alignnone size-medium wp-image-2411" alt="Bildschirmfoto 2013-03-08 um 12.24.55" src="https://nerdpress.org/wp-content/uploads/2013/03/Bildschirmfoto-2013-03-08-um-12.24.55-300x224.png" width="300" height="224" srcset="https://nerdpress.org/wp-content/uploads/2013/03/Bildschirmfoto-2013-03-08-um-12.24.55-300x224.png 300w, https://nerdpress.org/wp-content/uploads/2013/03/Bildschirmfoto-2013-03-08-um-12.24.55-1024x767.png 1024w, https://nerdpress.org/wp-content/uploads/2013/03/Bildschirmfoto-2013-03-08-um-12.24.55.png 1559w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Its hosted on <a href="http://jsfiddle.net/">jsfiddle.net</a> and enables you to create Bookmarklets which use jQuery based on the code i found here:<br />
<a href="http://coding.smashingmagazine.com/2010/05/23/make-your-own-bookmarklets-with-jquery/">http://coding.smashingmagazine.com/2010/05/23/make-your-own-bookmarklets-with-jquery/</a></p>
<p>It also features Javascript Syntax Highlighting using <a href="http://codemirror.net/">http://codemirror.net/</a>.</p>
<p>*UPDATE*<br />
this tool now (also) lives on <a href="https://github.com/gherkins/bookmarklet-generator">https://github.com/gherkins/bookmarklet-generator</a></p>The post <a href="https://nerdpress.org/2013/03/08/jsfiddle-bookmarklet-generator-with-jquery-codemirror/">JSfiddle Bookmarklet Generator with jQuery & Codemirror</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
					<wfw:commentRss>https://nerdpress.org/2013/03/08/jsfiddle-bookmarklet-generator-with-jquery-codemirror/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
