<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Robert Wade on Medium]]></title>
        <description><![CDATA[Stories by Robert Wade on Medium]]></description>
        <link>https://medium.com/@treetop1500?source=rss-51cf64d15d71------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YmCcJx-09HvdwsVLidDd7Q.jpeg</url>
            <title>Stories by Robert Wade on Medium</title>
            <link>https://medium.com/@treetop1500?source=rss-51cf64d15d71------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 14:57:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@treetop1500/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Setting up ElasticSearch with Symfony3 and Platform.sh]]></title>
            <link>https://medium.com/@treetop1500/setting-up-elasticsearch-with-symfony3-and-platform-sh-4041b8ca1f43?source=rss-51cf64d15d71------2</link>
            <guid isPermaLink="false">https://medium.com/p/4041b8ca1f43</guid>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <dc:creator><![CDATA[Robert Wade]]></dc:creator>
            <pubDate>Mon, 23 Oct 2017 21:02:33 GMT</pubDate>
            <atom:updated>2017-10-23T21:02:33.116Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R0g-pErij1FhjezXquJATA.jpeg" /></figure><p>Following are instructions for setting up and configuring ElasticSearch 5.6 with Symfony3 on Platform.sh (and locally).</p><h3>Install ElasticSearch Locally:</h3><p>For this I used Homebrew. The process is straightforward:</p><p>brew install elasticsearch</p><p>To run Elasticsearch, you should be able to open a terminal and type:</p><p>elasticsearch</p><h3>Configuration for local/platform environments</h3><p>Since we need to be able to run elasticsearch both locally and in the platform environments we need to configure for both.</p><h4>Local Config</h4><p>These are your local configuration parameters for your ElasticServer instance. Make sure to update parameters.yml.dist also.</p><pre><em>#app/config/parameters.yml<br></em><strong>parameters</strong>:<br>    ...</pre><pre>    <strong>elasticsearch_host</strong>: 127.0.0.1<br>    <strong>elasticsearch_port</strong>: 9200</pre><h4>Platform Config</h4><p>This will override your local config for these parameters when in the Platform.sh environment.</p><pre><strong>&lt;?php</strong></pre><pre>// app/config/parameters_platform.php</pre><pre>$relationships = getenv(&quot;PLATFORM_RELATIONSHIPS&quot;);<br>if<strong> </strong>(!$relationships) {<br>    return;<br>}<br><br>$relationships = json_decode(base64_decode($relationships), true);<br><br>foreach<strong> </strong>($relationships[&#39;elasticsearch&#39;] <strong>as </strong>$endpoint) {<br>    $container-&gt;setParameter(&#39;<strong>elasticsearch_host</strong>&#39;, $endpoint[&#39;host&#39;]);<br>    $container-&gt;setParameter(&#39;<strong>elasticsearch_port</strong>&#39;, $endpoint[&#39;port&#39;]);<br>}</pre><p>Also add the service to <em>.platform/services.yaml</em></p><pre><em>#.platform/services.yaml</em></pre><pre><strong>sitesearch:<br>    type: </strong>elasticsearch:5.2<br>    <strong>disk: </strong>1024</pre><p><em>…and the relationship to .platform.app.yaml</em></p><pre><em>#.platform.app.yaml</em></pre><pre><strong>relationships:<br>    ...</strong><br>    <strong>elasticsearch: </strong>&quot;sitesearch:elasticsearch&quot;</pre><h3>Install the FOS Elastica Bundle:</h3><p>Follow the installation and configuration instructions available here:</p><p><a href="https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/Resources/doc/setup.md">https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/Resources/doc/setup.md</a></p><p>I went ahead and set up an index on one entity only for testing purposes. My config looks like this:</p><pre><em>#app/config/config.yml<br></em><strong>fos_elastica:<br>    clients:<br>        default: </strong>{ <strong>host: </strong>&quot;%elasticsearch_host%&quot;, <strong>port: </strong>&quot;%elasticsearch_port%&quot; }<br>    <strong>indexes:<br>        app:<br>            types:<br>                work:<br>                    properties:<br>                        title: </strong>~<br>                        <strong>description: </strong>~<br>                        <strong>intro: </strong>~<br>                    <strong>persistence:</strong><em><br>                        </em><strong>driver: </strong>orm<br>                        <strong>model: </strong>AppBundle\Entity\Post<br>                        <strong>provider: </strong>~<br>                        <strong>finder: </strong>~</pre><p>Using parameters for the client, you can run your local or platform ElasticSearch instance accordingly.</p><p>While ElasticSearch is running, run the following command to populate your index:</p><pre>php bin/console fos:elastica:populate</pre><p>You’ll also want to add that command to your deploy hook in your platform config.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4041b8ca1f43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Custom HTTP headers in your Symfony controller.]]></title>
            <link>https://medium.com/@treetop1500/setting-custom-http-headers-in-your-symfony-controller-79039a59bf7d?source=rss-51cf64d15d71------2</link>
            <guid isPermaLink="false">https://medium.com/p/79039a59bf7d</guid>
            <category><![CDATA[twig]]></category>
            <category><![CDATA[header]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Robert Wade]]></dc:creator>
            <pubDate>Fri, 26 May 2017 17:51:54 GMT</pubDate>
            <atom:updated>2017-05-26T17:59:55.173Z</atom:updated>
            <content:encoded><![CDATA[<p>Occasionally you’ll need to send a custom header with your response in Symfony controller action and simply returning the rendered Twig template won’t cut it.</p><p>In my case I have a set of links that are being sent out to some potential clients. I don’t want to secure the pages as the content isn’t really sensitive and I don’t want to burden the recipient with authentication. However, I do want to at least try and prevent these pages from being indexed by search engines and somehow turning up in search results.</p><p><strong>Step 1.</strong></p><p>The first measure I took (the old standby) was to simply add the meta robots tag and set it to no-index. I have a ‘meta’ block in my base template, so I simply added this to my Twig template that extends it for this application:</p><pre>{% <strong>block </strong>meta %}<br>    {{ parent() }}<br>    &lt;meta name=&quot;robots&quot; content=&quot;noindex&quot; /&gt;<br>{% <strong>endblock </strong>%}</pre><p><strong>Step 2.</strong></p><p>To take this a bit further I wanted to set a the X-Robots header in the response as an added measure. It may be redundant but at the end of the day, I’ll feel better having it in place.</p><p>Here’s the original controller action:</p><pre><em>/**<br> * </em><strong><em>@param </em></strong><em>$slug<br> * </em><strong><em>@return </em></strong><em>Response<br> */<br></em><strong>public function </strong>indexAction($slug)<br>{<br><br>    $em = $this-&gt;getDoctrine()-&gt;getManager();<br>    $lead = $em-&gt;getRepository(&#39;MyBundle:Lead&#39;)-&gt;findOneBy(<strong>array</strong>(&#39;slug&#39;=&gt;$slug));<br><br>    <br>    <strong>return </strong>$this-&gt;render(&#39;MyBundle:Default:index.html.twig&#39;, <strong>array</strong>(<br>        &#39;lead&#39; =&gt; $lead,<br>    ));<br>}</pre><p>As you can see, the indexAction method simply returns a rendered Twig template. I need to make sure that response also has the appropriate header set.</p><p>Here’s the updated controller action:</p><pre><em>/**<br> * </em><strong><em>@param </em></strong><em>$slug<br> * </em><strong><em>@return </em></strong><em>Response<br> */<br></em><strong>public function </strong>indexAction($slug)<br>{<br><br>    $em = $this-&gt;getDoctrine()-&gt;getManager();<br>    $lead = $em-&gt;getRepository(&#39;MyBundle:Lead&#39;)-&gt;findOneBy(<strong>array</strong>(&#39;slug&#39;=&gt;$slug));<br><br>    $response = <strong>new </strong>Response($this-&gt;renderView(&#39;MyBundle:Default:index.html.twig&#39;, <strong>array</strong>(<br>        &#39;lead&#39; =&gt; $lead,<br>    )),200<br>    );<br><br>    $response-&gt;headers-&gt;set(&#39;X-Robots-Tag&#39;,&#39;noindex&#39;);<br><br>    <strong>return </strong>$response;<br>    <br>}</pre><p>As you can seem I’m now creating an HTTP response object, populating it’s content with the rendered twig view, and setting the X-Robots-tag header before returning the response.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79039a59bf7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using PHP’s Built in Server for Local Development]]></title>
            <link>https://medium.com/@treetop1500/using-phps-built-in-server-for-local-development-11bb776509fd?source=rss-51cf64d15d71------2</link>
            <guid isPermaLink="false">https://medium.com/p/11bb776509fd</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[wordpress]]></category>
            <dc:creator><![CDATA[Robert Wade]]></dc:creator>
            <pubDate>Thu, 27 Apr 2017 14:15:07 GMT</pubDate>
            <atom:updated>2017-04-27T14:15:07.707Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the challenges we face as developers is how to set up a web server for local development. I’ve been back and forth with Apple’s default Apache installation and setting up an AMP stack with Homebrew. Personally, I don’t care for the server side of this business. I’m a designer and a developer and sitting around configuring servers and troubleshooting these environments drives me crazy. It seems every time I have a major OS upgrade, I’m spending hours reinstalling and configuring my local server. No thanks.</p><blockquote>Note: I develop locally on a Mac Powerbook Pro using Homebrew PHP 7.0, Homebrew MySQL, and PHPStorm.</blockquote><p><strong>PHP Built in Server to the rescue</strong></p><p>When I started using Symfony as my primary development framework, I quickly became a fan of the PHP built in server and started using it over Apache. I found that over time running an Apache server locally would tie up resources, slow my machine down, and eventually I’d be restarting it. With the built in server, you simply start it with a short console command and kill it when you’re done. In Symfony that command looks like this:</p><pre>php bin/console server:start</pre><pre>// or</pre><pre>php bin/console server:stop</pre><p>And now your Symfony application is running on port 8000 at localhost. No Apache needed.</p><blockquote>Under the hood this console command is simply invoking the built in PHP CLI commands to start and stop the server.</blockquote><p><strong>Using the built in server for non-Symfony sites.</strong></p><p>Occasionally I have the painful displeasure to work on PHP sites that don’t utilize Symfony. In a recent endeavor I had to work locally to troubleshoot some issues on a Wordpress site, and rather than go thru the process of configuring Apache with vhosts and all that, I opted to use the PHP Built in Server.</p><blockquote>Wordpress doesn’t come with nifty server console commands like Symfony does, however it does run on PHP, so we can just invoke the commands natively.</blockquote><p>For this project I wanted to use a local domain vs. “localhost” for clarity, so the first step was to set up a host in my /etc/hosts files to point to localhost. Using vim or nano, modify your /etc/hosts file to include a line such as:</p><pre>127.0.0.1 mysite.local</pre><p>This will be the domain I use to access my site locally.</p><p>The next step is to define the WP_HOME and WP_SITEURL variables in your wp_config file. We use a wp-config-local.php file for local development so that we don’t modify the actual production wp-config.php file. In your local config file add the following lines:</p><pre>define(&#39;WP_HOME&#39;,&#39;http://mysite.local:8080&#39;);<br>define(&#39;WP_SITEURL&#39;,&#39;http://mysite.local:8080&#39;);</pre><blockquote>When I run Wordpress locally, I use port 8080 with it. I use port 8000 for Symfony projects. Of course you can choose your own ports if you like.</blockquote><p>Wordpress has a nasty habit of storing references to these domains in your actual database. So if you’ve imported a database from your live site into your local MySQL to work from, you’ll need to make sure references to those URLs are updated locally to work with your local domain. Using a tool like Sequel Pro or PHPMyAdmin, log into your local database and open the wp_options table. Search for the records who’s <em>option_name properties are </em><strong>home</strong> and <strong>site_url. </strong>Change both of these to:</p><pre>http://mysite.local:8080</pre><p>One last bit of config is to turn off canonical redirects in Wordpress. If you don’t do this Wordpress will remove the port number from your addresses and cause a lot of 404 errors. In your theme’s functions.php file, add the following line just after the opening &lt;?php tag:</p><pre>remove_filter(&#39;template_redirect&#39;,&#39;redirect_canonical&#39;);</pre><blockquote>You may want to remove this prior to pushing your work to production. Having this in place in production could cause issues with your permalinks.</blockquote><p>Now you can run your server and work locally without Apache. Open a terminal and first cd to your project root, and then start the server:</p><pre>cd ~/sites/mysite.local<br>php -S mysite.local:8080</pre><p>You will now see some feedback in your terminal letting you know that your PHP server is listening for traffic on <a href="http://mysite.local:8080/">http://mysite.local:8080</a>. To stop the server simply hit Ctrl+C in your running terminal.</p><p>You can now browse that address while you work locally on your Wordpress site. Enjoy!</p><p><strong>Further Reading:</strong></p><p><a href="http://php.net/manual/en/features.commandline.webserver.php">http://php.net/manual/en/features.commandline.webserver.php</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11bb776509fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Twig Data Tests]]></title>
            <link>https://medium.com/@treetop1500/twig-data-tests-1a26e9348e13?source=rss-51cf64d15d71------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a26e9348e13</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[twig]]></category>
            <dc:creator><![CDATA[Robert Wade]]></dc:creator>
            <pubDate>Wed, 12 Apr 2017 15:28:10 GMT</pubDate>
            <atom:updated>2017-08-30T12:44:23.941Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*codU5Wr0AXKSrlC-oIZSlA.jpeg" /></figure><p>Twig comes with a great set of comparison tools for you data, but if you’re new to Twig, they can be slightly confusing. Here’s a quick rundown on data tests in twig:</p><h3>boolean</h3><p>Tests wether a variable is exactly true.</p><pre><strong>{% if myVar %} {{ myVar }} {% endif %}<br></strong>// throws error as myVar is not defined</pre><pre><strong>{% set myVar = true %}<br>{% if myVar %} FooBar! {% endif %}<br></strong>// &#39;FooBar!&#39;</pre><pre><strong>{% set myVar = true %}<br>{% if myVar == true %} FooBar! {% endif %}<br></strong>// &#39;FooBar!&#39;</pre><h3>defined</h3><p>Tests wether a variable is defined in the current current context (if it exists)</p><pre><strong>{% if myVar is defined %} {{ myVar }} {% endif %}<br></strong>// nothing, but won&#39;t error.</pre><pre><strong>{% set myVar = &#39;foo&#39; %}<br>{% if myVar is defined %} {{ myVar }} {% endif %}<br></strong>// &#39;foo&#39;</pre><h3>null</h3><p>Tests wether a variable is exactly null</p><pre><strong>{% if myVar is null %} {{ myVar }} {% endif %}<br></strong>// throws error as myVar is not defined</pre><pre><strong>{% set myVar = &#39;foo&#39; %}<br>{% if myVar is not null %} {{ myVar }} {% endif %}</strong><br>// &#39;foo&#39;</pre><pre><strong>{% set myVar = null %}<br>{% if myVar is not null %} {{ myVar }} {% endif %}</strong><br>// nothing</pre><h3>empty</h3><p>Tests wether a variable is either:</p><ul><li>exactly null</li><li>exactly false</li><li>an empty string</li><li>an empty array</li><li>an empty hash</li></ul><pre><strong>{% if myVar is empty %} {{ myVar }} {% endif %}<br></strong>// throws error as myVar is not defined</pre><pre><strong>{% set myVar = &#39;foo&#39; %}<br>{% if myVar is not empty %} {{ myVar }} {% endif %}<br></strong>// foo</pre><pre><strong>{% set myVar = true %}<br>{% if myVar is not empty %} FooBar! {% endif %}<br></strong>// FooBar!</pre><pre><strong>{ &#39;foo&#39;: &#39;foo&#39;, &#39;bar&#39;: &#39;bar&#39; }<br>{% if foo is not empty %} {{ foo }} {% endif %}<br></strong>// &#39;foo&#39;</pre><pre><strong>{% set myVar = null %}<br>{% if foo is not null %} FooBar! {% endif %}<br></strong>// &#39;FooBar!&#39;</pre><h3>same as()</h3><p>Tests wether a variable is the same as another including datatype (the equivalent of ===)</p><pre><strong>{% if myVar is same as(yourVar) %} {{ myVar }} {% endif %}<br></strong>// throws error as myVar and yourVar are not defined</pre><pre><strong>{% set myVar = {&#39;me&#39;:true, &#39;you&#39;:true} %}<br>{% if myVar.me is same as(myVar.you) %} Same! {% endif %<br></strong>// &#39;Same!&#39;</pre><pre><strong>{% set myVar = {&#39;me&#39;:true, &#39;you&#39;:&#39;true&#39;} %}<br>{% if myVar.me is same as(myVar.you) %} Same! {% endif %}<br></strong>// Nothing</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a26e9348e13" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using a Data Transformer Class for Simple Markdown Syntax in Symfony]]></title>
            <link>https://medium.com/@treetop1500/using-a-data-transformer-class-for-simple-markdown-syntax-in-symfony-15f15e9fdbf2?source=rss-51cf64d15d71------2</link>
            <guid isPermaLink="false">https://medium.com/p/15f15e9fdbf2</guid>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Robert Wade]]></dc:creator>
            <pubDate>Fri, 24 Mar 2017 17:22:46 GMT</pubDate>
            <atom:updated>2017-03-24T17:23:52.614Z</atom:updated>
            <content:encoded><![CDATA[<p>Yesterday I did a write up on an alternative to using a WYSIWIG for some basic mark up (bold, italic) for single line inputs using markdown syntax and a custom Twig Filter. As is the usual case, I thought I had a fantastic solution going until that evening when I was sitting on the couch watching Purdue get destroyed by Kansas and I had an epiphany.</p><p><a href="https://medium.com/@treetop1500/to-wysiwyg-or-not-to-wysiwyg-5b60acbc452b#.yrw05ib6j">You can read the initial post here.</a></p><p>It occurred to me that the problem with using a Twig filter is that you have to always ensure this filter is in place anywhere you output this property:</p><pre>{{ title|parseInput }}</pre><p>Obviously I’d rather not have to do this sort of thing in Twig all the time. It’s just one more thing to keep track of.</p><p><strong>Data Transformers to the Rescue</strong></p><p>Why I hadn’t thought to use a Data Transformer class initially escapes me but it seems the perfect use case for this type of scenario, and much less obtrusive than the Twig Filter I have to keep track of in my views.</p><p>In a nutshell, a data transformer is a class that you associate with a particular piece of data which manipulates your data going into and coming out of the database for you. In my case I want to input a string into the form field like this:</p><pre>Hey Here&#39;s some **bold** stuff</pre><p>And have it stored in the database as:</p><pre>Hey Here&#39;s some &lt;strong&gt;bold&lt;/strong&gt; stuff</pre><p>But have it also return to it’s initial state when I edit the record in a form again.</p><p>This is the exact job of a DataTransformer Class. Here’s how I got this working.</p><p><strong>Step 1. Create the Data Transformer Class</strong></p><pre><strong>&lt;?php<br>namespace </strong>Common\ContentBundle\DataTransformer;<br><br><strong>use </strong>Symfony\Component\Form\DataTransformerInterface;<br><br><em>/**<br> * Class MarkdownTransformer<br> * </em><strong><em>@package </em></strong><em>Common\ContentBundle\DataTransformer<br> */<br></em><strong>class </strong>MarkdownTransformer <strong>implements </strong>DataTransformerInterface<br>{<br><br>    <em>/**<br>     * Transforms the HTML string back to markdown.<br>     *<br>     * </em><strong><em>@param </em></strong><em>string $val<br>     * </em><strong><em>@return </em></strong><em>string<br>     */<br>    </em><strong>public function </strong>transform($val)<br>    {<br>        // strong to double asterisks:<br>        $val = preg_replace(&quot;/\&lt;strong\&gt;(.+?)\&lt;\/strong\&gt;/i&quot;, &quot;**$1**&quot;, $val);<br><br>        // italic to double underscores:<br>        $val = preg_replace(&quot;/\&lt;em\&gt;(.+?)\&lt;\/em\&gt;/i&quot;, &quot;__$1__&quot;, $val);<br><br>        <strong>return </strong>$val;<br>    }<br><br>    <em>/**<br>     * Transforms the markdown string to html.<br><br>     * </em><strong><em>@param  </em></strong><em>string $val<br>     * </em><strong><em>@return </em></strong><em>string<br>     */<br>    </em><strong>public function </strong>reverseTransform($val)<br>    {<br>        // double asterisks to strong:<br>        $val = preg_replace(&quot;/\*\*(.+?)\*\*/i&quot;, &quot;&lt;strong&gt;$1&lt;/strong&gt;&quot;, $val);<br><br>        // double underscores to italic:<br>        $val = preg_replace(&quot;/\_\_(.+?)\_\_/i&quot;, &quot;&lt;em&gt;$1&lt;/em&gt;&quot;, $val);<br><br>        <strong>return </strong>$val;<br>    }<br>}</pre><p>This has class has two primary methods:</p><ol><li><strong>transform</strong> — which transforms data coming out of the database and into your form fields.</li><li><strong>reverseTransform</strong> — which transforms your data going into the database from your form fields.</li></ol><p><strong>Step 2. Create a form type extension for the Markdown input type</strong></p><p>In my case, this input type will be used in several different places, so in keeping best practices in mind by creating reusable code, I opted to create a form type extension of MarkDown type, where I can assign the data transformer once, and not have to do it everywhere I want this functionality. Here is my Markdown form type:</p><pre><strong>&lt;?php<br>namespace </strong>Common\Form;<br><br><strong>use </strong>Common\ContentBundle\DataTransformer\MarkdownTransformer;<br><strong>use </strong>Symfony\Component\Form\AbstractType;<br><strong>use </strong>Symfony\Component\Form\Extension\Core\Type\TextType;<br><strong>use </strong>Symfony\Component\OptionsResolver\OptionsResolver;<br><strong>use </strong>Symfony\Component\Form\FormBuilderInterface;<br><br><em>/**<br> * Class MarkDownType<br> * </em><strong><em>@package </em></strong><em>Common\Form<br> */<br></em><strong>class </strong>MarkDownType <strong>extends </strong>AbstractType<br>{<br><br>    <em>/**<br>     * </em><strong><em>@param </em></strong><em>FormBuilderInterface $builder<br>     * </em><strong><em>@param </em></strong><em>array                $options<br>     */<br>    </em><strong>public function </strong>buildForm(FormBuilderInterface $builder, <strong>array </strong>$options)<br>    {<br>        $transformer = <strong>new </strong>MarkdownTransformer();<br>        $builder-&gt;addModelTransformer($transformer);<br>    }<br><br>    <em>/**<br>     * </em><strong><em>@param </em></strong><em>OptionsResolver $resolver<br>     */<br>    </em><strong>public function </strong>configureOptions(OptionsResolver $resolver)<br>    {<br>        $resolver-&gt;setDefaults(<strong>array</strong>(<br>            &#39;attr&#39; =&gt; <strong>array</strong>(<br>                &#39;help&#39; =&gt; &#39;To bold words, surround them with double asterisks. e.g.: This is &lt;strong&gt;**bold**&lt;/strong&gt; now. To emphasize words surround the with double underscores.&#39;,<br>            ),<br>        ));<br>    }<br><br>    <em>/**<br>     * </em><strong><em>@return </em></strong><em>mixed<br>     */<br>    </em><strong>public function </strong>getParent()<br>    {<br>        <strong>return </strong>TextType::<em>class</em>;<br>    }<br>}</pre><p>This allows me to not only apply the DataTransformer once in my code, but also I can set some sensible defaults for the form type like my custom ‘help’ attribute, making these consistent everywhere I use this form type.</p><p>Now in my form I only have to include the field as such:</p><pre>...<br><strong>public function </strong>buildForm(FormBuilderInterface $builder, <strong>array </strong>$options)<br>{<br>    $builder<br>        -&gt;add(&#39;title&#39;, MarkDownType::<em>class</em>, <strong>array</strong>(<br>            &#39;required&#39; =&gt; <strong>true</strong>,<br>        ))<br>}<br>...</pre><p>And that’s it. Now I can render my title field containing HTML in my twig template with the standard raw filter and not have to worry about custom filters.</p><pre>{{ title | raw }}</pre><p>Hope you enjoyed this, and here is a Gist of the combined code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b946be753c1332a1904914c0ba4f14c/href">https://medium.com/media/4b946be753c1332a1904914c0ba4f14c/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15f15e9fdbf2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To WYSIWYG or not to WYSIWYG]]></title>
            <link>https://medium.com/@treetop1500/to-wysiwyg-or-not-to-wysiwyg-5b60acbc452b?source=rss-51cf64d15d71------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b60acbc452b</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[wysiwyg]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[twig]]></category>
            <dc:creator><![CDATA[Robert Wade]]></dc:creator>
            <pubDate>Thu, 23 Mar 2017 14:38:36 GMT</pubDate>
            <atom:updated>2017-03-24T17:23:43.139Z</atom:updated>
            <content:encoded><![CDATA[<p>Update! I have a better solution to this problem using data transformers:<br><a href="https://medium.com/@treetop1500/using-a-data-transformer-class-for-simple-markdown-syntax-in-symfony-15f15e9fdbf2#.7mtw003ez">https://medium.com/@treetop1500/using-a-data-transformer-class-for-simple-markdown-syntax-in-symfony-15f15e9fdbf2#.7mtw003ez</a></p><p>WYSYWIG editors are great and have come a long way since the early days of things like CKEditor and TinyMCE. I’ve recently fell in love with <a href="https://www.froala.com/wysiwyg-editor">Froala Editor</a> and have been implementing it regularly in CMS UIs that I build in Symfony/Twig. However sometimes having an editor like this is overkill, or introduces complexities and problems even when you strip down the toolset to the bare minimum.</p><p><strong>The situation:</strong></p><p>I’m currently working on website where the administrators have the ability to create sections or modules on a particular view, one of the properties of this section entity is a <em>title</em> which is represented by an <strong>H2</strong> tag in the code. The design for these sections require that certain words in these titles can be bolded, and some words might have emphasis. I could simply create a separate instance of my Froala editor with a toolset featuring only Bold and Italic which would apply the proper <strong>strong</strong> and <strong>em</strong> tags but there’s a couple problems with this situation:</p><p><strong>Problem 1:</strong></p><p>WYSIWIG editors like Froala and CKEditor are built on the HTML textarea object, which allow multiline input. Something I don’t want on these particular titles because I’m going for a fluid design and I don’t want the administrator improperly forcing breaks.</p><p><strong>Problem 2:</strong></p><p>The outcome is potentially wrapped (depending on your config) in other tags. In my case I’m wrapping the value of title in my Twig template with an H2, however the Froala editor content gets stored wrapped in a paragraph tag, so I end up with something like this in the compiled source:</p><pre>&lt;h2&gt;&lt;p&gt;This title is whacked.&lt;/p&gt;&lt;h2&gt;</pre><p>As you can imagine this causes some serious display problems for me, particularly regarding line-height.</p><p><strong>The Solution</strong></p><p>I opted to go with a simpler solution using a standard text input and allowing 2 elements of style markup using character sequences:</p><ol><li>To bold a string in the title, simply surround it with double asterisks as such: <br>This is my **better** title.</li><li>To emphasize a string in the title, surround it with double underscores like this: <br>This is another __better__ title.</li></ol><p>So for the administrator, they now just see a title field in their form with a help tip below it explaining the options like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*af112SnFK7ZG7WNZNuFfAg.png" /></figure><p>Behind the scenes we simply set up a <a href="http://symfony.com/doc/current/templating/twig_extension.html">custom Twig Filter</a> to look for these patterns and replace them with the proper content:</p><pre>&lt;?php<br>namespace MyBundle\Twig\Extension;</pre><pre>class MyTwigExtension extends \Twig_Extension<br>{<br>  public function getFilters()<br>  {<br>    return array(<br>      &#39;parseInput&#39; =&gt; new \Twig_SimpleFilter(<br>        &#39;parseInput&#39;,<br>        array($this, &#39;parseInput&#39;),<br>        array(&#39;is_safe&#39; =&gt; array(&#39;html&#39;))),<br>    );<br>  }</pre><pre>  public function parseInput($val)<br>  {<br>    // double asterisks to strong:<br>    $val = preg_replace(<br>       &quot;/\*\*(.+?)\*\*/i&quot;,<br>       &quot;&lt;strong&gt;$1&lt;/strong&gt;&quot;,<br>       $val<br>    );</pre><pre>  // double underscores to italic:<br>  $val = preg_replace(<br>    &quot;/\_\_(.+?)\_\_/i&quot;,<br>    &quot;&lt;em&gt;$1&lt;/em&gt;&quot;,<br>    $val<br>    );<br>        <br>    return $val;<br>  }<br>}</pre><p>Here I’ve set up a<em> parseInput</em> twig filter that will use regular expressions to match strings surrounded by double asterisks or double underscores and convert them to the proper HTML tags at render time. You’ll notice that I’ve made sure to use non-greedy match (?) in this which will help when you have multiple cases of parsed words like: <strong>This</strong> is a <strong>fantastic</strong> title.</p><p>In order to use your custom filter in your twig template, you’ll simply implement it as you would any twig filter:</p><pre>{{ title|parseInput }}</pre><p>What I like about this solution is that you can also nest the markup as well as have multiple instances of marked up strings in your code. So you can do things like:</p><pre>__This **entire title** is emphasized and **some words** are bold__</pre><p><strong>Which produces:</strong></p><p><em>This </em><strong><em>entire title</em></strong><em> is emphasized and </em><strong><em>some words</em></strong><em> are bold</em></p><p><strong>Disclaimer</strong></p><p>I am not an expert on regular expressions and know enough to be dangerous. There might be a more efficient way to handle this in one preg_replace method. If you know of a way, feel free to comment, and I hope you enjoyed this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b60acbc452b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up a Sortable Drag ‘n Drop Interface for Symfony Entities.]]></title>
            <link>https://medium.com/@treetop1500/setting-up-a-sortable-drag-n-drop-interface-for-symfony-entities-7f0c84ac0c8e?source=rss-51cf64d15d71------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f0c84ac0c8e</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[drag-and-drop]]></category>
            <category><![CDATA[doctrine]]></category>
            <category><![CDATA[symfony]]></category>
            <dc:creator><![CDATA[Robert Wade]]></dc:creator>
            <pubDate>Wed, 22 Mar 2017 14:53:45 GMT</pubDate>
            <atom:updated>2017-03-22T16:56:07.612Z</atom:updated>
            <content:encoded><![CDATA[<p>In a recent training opportunity we had at Gray Loon I used my time to figure out how to set up something that I felt like had been missing from some of the CMS builds we’ve done in <em>Symfony</em> — having an interface to sort a collection of entities via drag and drop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*2qlyoWCTokEx8VpRasqIdw.gif" /></figure><p>What I found out was that with the right combination of techniques it wasn’t a difficult task to accomplish. Here’s what you need:</p><ol><li><strong>Drag and drop capability.</strong> Fortunately HTML5 which is now widely supported in modern browsers has native drag and drop capability complete with all the Javascript events and event handling you’ll need</li><li><strong>A property and mechanism for sorting your entities</strong>. This is where Doctrine extensions come in handy. I used the Doctrine Sortable extension with the Gedmo Doctrine extensions bundle.</li><li><strong>A way to identify items as sortable in your interface</strong>. Using native HTML5 drag and drop, you can use the draggable attribute on your table rows.</li><li><strong>A controller action and some routing to handle the sort action</strong>. Easily set up in <em>Symfony</em>.</li><li><strong>Some Javascript</strong> for event handling and some Ajax to do the legwork seamlessly behind the scenes without page refresh.</li></ol><p><strong>Step 1. Configure and Install the Doctrine Extensions</strong></p><p>I won’t go into full detail on how to set up Doctrine extensions here, because the documentation available is very straightforward. I use the <a href="https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/symfony2.md">Gedmo Doctrine Extensions bundle</a> in <em>Symfony</em>. In a nutshell, we’ll be using the Sortable extension which gives our entity a <em>position</em> property. The nice thing about using the Sortable extension over something like a standard integer property, is that all entities in the same sortable group are adjusted when you alter the sort position of just one of them in the same group. In other words, if you move an instance to position 1 in the sort, and already have another with that same position, Doctrine will handle adjusting the sort on it, as well as any other instances that need to be ‘bumped’ as well, eliminating the need to adjust the sort on multiple instances.</p><p>Ensure that you have your doctrine_extensions.yml file set up to include the sortable listener service:</p><pre>//doctrine_extensions.yml</pre><pre>services:</pre><pre>...</pre><pre>gedmo.listener.sortable:</pre><pre>class: Gedmo\Sortable\SortableListener</pre><pre>tags:</pre><pre>- { name: doctrine.event_subscriber, connection: default }</pre><pre>calls:</pre><pre>- [ setAnnotationReader, [ &quot;@annotation_reader&quot; ] ]</pre><p><strong>Step 2. Make sure that your Entity is sortable:</strong></p><p>Add the ‘position’ private property (integer) to your entity and it’s getter/setter (example simplified for clarification). Don’t forget the use statement for the Gedmo Annotations.</p><pre>&lt;?php</pre><pre>namespace Common\ContentBundle\Entity;</pre><pre>...</pre><pre><strong>use Gedmo\Mapping\Annotation as Gedmo;</strong></pre><pre>class ProductCategory</pre><pre>{</pre><pre>...</pre><pre><strong>/**</strong></pre><pre><strong>* @var integer $position</strong></pre><pre><strong>*</strong></pre><pre><strong>* @Gedmo\Sortable()</strong></pre><pre><strong>* @ORM\Column(name=&quot;position&quot;, type=&quot;integer&quot;)</strong></pre><pre><strong>*/</strong></pre><pre><strong>private $position;</strong></pre><pre>...</pre><pre><strong>/**</strong></pre><pre><strong>* @return int</strong></pre><pre><strong>*/</strong></pre><pre><strong>public function getPosition()</strong></pre><pre><strong>{</strong></pre><pre><strong>return $this-&gt;position;</strong></pre><pre><strong>}</strong></pre><pre><strong>/**</strong></pre><pre><strong>* @param int $position</strong></pre><pre><strong>*/</strong></pre><pre><strong>public function setPosition($position)</strong></pre><pre><strong>{</strong></pre><pre><strong>$this-&gt;position = $position;</strong></pre><pre><strong>}</strong></pre><pre>...</pre><pre>}</pre><p><strong>Step 3.</strong></p><p><strong>Assign draggable properties to your table elements in your index.html.twig file.</strong></p><ul><li>The table itself should have a ‘sortable’ class.</li><li>Each draggable row needs to have the HTML5 draggable property set to true.</li><li>We need a way to reference the entity by <em>id</em> so we can update it in the controller. Setting the <em>rel</em> attribute to the entity ID is an easy way to achieve this.</li><li>You can show the position property if you wish. It is done so in this example, but it’s not necessary.</li></ul><pre>&lt;table <strong>class=&quot;sortable&quot;</strong>&gt;</pre><pre>&lt;thead&gt;</pre><pre>&lt;tr&gt;</pre><pre>&lt;th&gt;&amp;nbsp;&lt;/th&gt;</pre><pre>&lt;th&gt;Id&lt;/th&gt;</pre><pre>&lt;th&gt;Sort&lt;/th&gt;</pre><pre>&lt;th&gt;Title&lt;/th&gt;</pre><pre>&lt;/tr&gt;</pre><pre>&lt;/thead&gt;</pre><pre>&lt;tbody&gt;</pre><pre>{% for category in productCategories %}</pre><pre>&lt;tr <strong>draggable=&quot;true&quot; rel=&quot;{{ category.id }}&quot;</strong>&gt;</pre><pre>&lt;td&gt;&lt;i class=&quot;fa fa-arrows&quot;&gt;&lt;/i&gt;&lt;/td&gt;</pre><pre>&lt;td&gt;&lt;a href=&quot;{{ path(&#39;admin_productcategory_show&#39;, { &#39;id&#39;: category.id }) }}&quot;&gt;{{ category.id }}&lt;/a&gt;&lt;/td&gt;</pre><pre>&lt;td&gt;<strong>{{ category.position }}</strong>&lt;/td&gt;</pre><pre>&lt;td&gt;{{ category.title }}&lt;/td&gt;</pre><pre>&lt;/tr&gt;</pre><pre>{% endfor %}</pre><pre>&lt;/tbody&gt;</pre><pre>&lt;/table&gt;</pre><p><strong>Step 4. Add a Controller action for the sort</strong></p><p>This will be a controller action used in an Ajax request on successful “drop” events, so that the entity’s position property can be updated.</p><pre>&lt;?php</pre><pre>namespace Common\ContentBundle\Controller;</pre><pre>use Symfony\Component\HttpFoundation\Request;</pre><pre>use Symfony\Bundle\FrameworkBundle\Controller\Controller;</pre><pre>use Common\ContentBundle\Entity\ProductCategory;</pre><pre>/**</pre><pre>* ProductCategory controller.</pre><pre>*/</pre><pre>class ProductCategoryController extends Controller</pre><pre>{</pre><pre>...</pre><pre><strong>/**</strong></pre><pre><strong>* Resorts an item using it&#39;s doctrine sortable property</strong></pre><pre><strong>* @param integer $id</strong></pre><pre><strong>* @param integer $position</strong></pre><pre><strong>* @return \Symfony\Component\HttpFoundation\Response</strong></pre><pre><strong>*/</strong></pre><pre><strong>public function sortAction($id, $position)</strong></pre><pre><strong>{</strong></pre><pre><strong>$em = $this-&gt;getDoctrine()-&gt;getManager();</strong></pre><pre><strong>$productCategory = $em-&gt;getRepository(&#39;CommonContentBundle:ProductCategory&#39;)-&gt;find($id);</strong></pre><pre><strong>$productCategory-&gt;setPosition($position);</strong></pre><pre><strong>$em-&gt;persist($productCategory);</strong></pre><pre><strong>$em-&gt;flush();</strong></pre><pre><strong>$request = new Request();</strong></pre><pre><strong>return $this-&gt;indexAction($request);</strong></pre><pre><strong>}</strong></pre><pre>}</pre><p><strong>Step 5. Add the routing</strong></p><p>This is the route for your Ajax request to update the entity. It passes two arguments to the controller action created in step 4: <em>id </em>(The entity id grabbed from the <em>rel</em> attribute of the row, and <em>$position</em> (the new value that the entities position should be set to). Since you are using the Doctrine sortable extension, you need only set the position property of this entity and all others will adjust accordingly.</p><pre>admin_productcategory_sort:</pre><pre>path:     /admin/productcategory/sort/{id}/{position}</pre><pre>defaults: {_controller:&quot;CommonContentBundle:ProductCategory:sort&quot;}</pre><pre>methods:  GET</pre><p><strong>Step 6. Add some styling</strong></p><p>You’ll want to identify your rows as draggable and also indicate with some style what’s happening when you’re moving things around. I use SASS, so here is style snippet from my .scss file. Note: This is not vendor prefixed because I use auto-prefixer with Gulp for SASS compiling. If you don’t you’ll want to add vendor prefixes for user-select and draggable. These styles make sure that text selection doesn’t interfere with dragging functionality.</p><pre>[draggable] {</pre><pre>    user-select: none;</pre><pre>    -webkit-user-drag: element;</pre><pre>    cursor: move;</pre><pre>}</pre><pre>table.sortable {</pre><pre>    i.fa.fa-arrows {</pre><pre>        color: #999;</pre><pre>    }</pre><pre>    tr.over {</pre><pre>        border: 1px dashed red;</pre><pre>    }</pre><pre>}</pre><p><strong>Step 7. Add the Javascript</strong></p><p>This is the Javascript that I used. The majority of it was pulled from <a href="http://Add the Javascript This is the Javascript that I used.  The majority of it was pulled from the first resource mentioned in this doc.  I’ve altered it somewhat to interact with the database.  Ultimately it’s going to track the entity being dragged by it’s rel attribute, and capture the position it gets dropped on. These are the arguments passed via the route to the sort Action in the controller by the ajax call.  (Most of this is vanilla JS, however there is some jQuery in here too, so beware)">here</a>. I’ve altered it somewhat to interact with the database and put the methods in my adminNs namespace. Ultimately it’s going to track the entity being dragged by it’s <em>rel</em> attribute, and capture the position it gets dropped on. These are the arguments passed via the route to the sort Action in the controller by the Ajax call. (Most of this is vanilla JS, however there is some jQuery in here too, so beware).</p><pre>var adminNs =</pre><pre>{</pre><pre>initDraggableEntityRows: function() {</pre><pre>var dragSrcEl = null; // the object being drug</pre><pre>var startPosition = null; // the index of the row element (0 through whatever)</pre><pre>var endPosition = null; // the index of the row element being dropped on (0 through whatever)</pre><pre>var parent; // the parent element of the dragged item</pre><pre>var entityId; // the id (key) of the entity</pre><pre>function handleDragStart(e) {</pre><pre>dragSrcEl = this;</pre><pre>entityId = $(this).attr(&#39;rel&#39;);</pre><pre>dragSrcEl.style.opacity = &#39;0.4&#39;;</pre><pre>parent = dragSrcEl.parentNode;</pre><pre>startPosition = Array.prototype.indexOf.call(parent.children, dragSrcEl);</pre><pre>console.log(&quot;start: &quot;+startPosition);</pre><pre>e.dataTransfer.effectAllowed = &#39;move&#39;;</pre><pre>e.dataTransfer.setData(&#39;text/html&#39;, this.innerHTML);</pre><pre>console.log(entityId);</pre><pre>}</pre><pre>function handleDragOver(e) {</pre><pre>//console.log(&#39;drag over: &#39;+ e.target);</pre><pre>if (e.preventDefault) {</pre><pre>e.preventDefault(); // Necessary. Allows us to drop.</pre><pre>}</pre><pre>e.dataTransfer.dropEffect = &#39;move&#39;;  // See the section on the DataTransfer object.</pre><pre>return false;</pre><pre>}</pre><pre>function handleDragEnter(e) {</pre><pre>//console.log(&#39;drag enter: &#39;+ e.target);</pre><pre>this.classList.add(&#39;over&#39;);</pre><pre>}</pre><pre>function handleDragLeave(e) {</pre><pre>//console.log(&#39;drag leave: &#39;+ e.target);</pre><pre>this.classList.remove(&#39;over&#39;);  // this / e.target is previous target element.</pre><pre>}</pre><pre>function handleDrop(e) {</pre><pre>//console.log(&#39;drop: &#39;+ e.target);</pre><pre>//console.log(e.currentTarget);</pre><pre>//console.log(dragSrcEl);</pre><pre>if (e.stopPropagation) {</pre><pre>e.stopPropagation(); // stops the browser from redirecting.</pre><pre>}</pre><pre>// Don&#39;t do anything if dropping the same column we&#39;re dragging.</pre><pre>if (dragSrcEl != this) {</pre><pre>endPosition = Array.prototype.indexOf.call(parent.children, this);</pre><pre>console.log(&quot;end: &quot;+endPosition);</pre><pre>// Set the source column&#39;s HTML to the HTML of the column we dropped on.</pre><pre>dragSrcEl.innerHTML = this.innerHTML;</pre><pre>this.innerHTML = e.dataTransfer.getData(&#39;text/html&#39;);</pre><pre>// do the ajax call to update the database</pre><pre>$.ajax({</pre><pre>url: &#39;/admin/productcategory/sort/&#39;+entityId+&#39;/&#39;+endPosition,</pre><pre>})</pre><pre>.done(function(res) {</pre><pre>$(&quot;table.sortable tbody&quot;).replaceWith($(res).find(&quot;table.sortable tbody&quot;));</pre><pre>})</pre><pre>.fail(function(err) {</pre><pre>alert(&quot;An error occurred while sorting. Please refresh the page and try again.&quot;)</pre><pre>})</pre><pre>.always(function() {</pre><pre>adminNs.initDraggableEntityRows();</pre><pre>});</pre><pre>}</pre><pre>return false;</pre><pre>}</pre><pre>function handleDragEnd(e) {</pre><pre>//console.log(&#39;drag end: &#39;+ e.target);</pre><pre>this.style.opacity = &#39;1&#39;;  // this / e.target is the source node.</pre><pre>[].forEach.call(rows, function (row) {</pre><pre>row.classList.remove(&#39;over&#39;);</pre><pre>});</pre><pre>}</pre><pre>var rows = document.querySelectorAll(&#39;table.sortable &gt; tbody tr&#39;);</pre><pre>[].forEach.call(rows, function(row) {</pre><pre>row.addEventListener(&#39;dragstart&#39;, handleDragStart, false);</pre><pre>row.addEventListener(&#39;dragenter&#39;, handleDragEnter, false);</pre><pre>row.addEventListener(&#39;dragover&#39;, handleDragOver, false);</pre><pre>row.addEventListener(&#39;dragleave&#39;, handleDragLeave, false);</pre><pre>row.addEventListener(&#39;drop&#39;, handleDrop, false);</pre><pre>row.addEventListener(&#39;dragend&#39;, handleDragEnd, false);</pre><pre>});</pre><pre>},</pre><pre>/**</pre><pre>* Primary Admin initialization method.</pre><pre>* @returns {boolean}</pre><pre>*/</pre><pre>init: function() {</pre><pre>...</pre><pre>this.initDraggableEntityRows();</pre><pre>return true;</pre><pre>}</pre><pre>};</pre><pre>$(function() {</pre><pre>adminNs.init();</pre><pre>});</pre><p><strong>Lessons Learned</strong></p><ul><li>This was easier than expected, and will be a nice addition to our Symfony CMS UI.</li><li>I was not aware when starting this that there was a native HTML5/Javascript implementation for DnD. I was going into this dreading having to use jQuery UI or something, and was pleasantly suprised.</li><li>Every time I make myself use a new doctrine extension I want to kick myself for not using it earlier. The sortable extension is super easy to implement and pretty much does all the hard work for you when managing entities. Very useful extension.</li></ul><p><strong>Resources</strong></p><p><a href="https://www.html5rocks.com/en/tutorials/dnd/basics/">https://www.html5rocks.com/en/tutorials/dnd/basics/</a></p><p><a href="http://symfony.com/doc/current/doctrine/common_extensions.html">http://symfony.com/doc/current/doctrine/common_extensions.html</a></p><p><a href="https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/symfony2.md">Atlantic18/DoctrineExtensions</a></p><p><strong>GitHub Gist</strong></p><p>Unfortunately Medium doesn’t handle pasting single files out of a multi-file Gist, and I prefer not to have every file as a separate Gist (hence the default markup in the examples above). So here’s the complete Gist of it…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b4a43bc5e63ede754e909a1cac25a47/href">https://medium.com/media/0b4a43bc5e63ede754e909a1cac25a47/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f0c84ac0c8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>