warning: Creating default object from empty value in /var/drupal/modules/taxonomy/ on line 33.

Doctrine and Generated Columns

Using a smart SQL query with subqueries, we reduced the time to build a data export by a factor of (at least) 50. On the development system with little data, we got from the response from 11 seconds to about 0.25 seconds.

To make this possible, we had to use a generated column to be able to create an index on a field inside a JSON column. Doctrine does not know Generated Columns, so we had to hide the column and index from the Doctrine Schema Generator.

Varnish and HTTPS with Apache

Today I wanted to run a website with HTTPS and Varnish. Varnish itself does not support SSL, and for good reasons. So the setup we need is HTTPS termination => Varnish => Webserver. So we need a software that can handle HTTPS and forward requests over HTTP to Varnish. A couple of options for HTTPS termination are HAProxy, Nginx, Squid or Apache. I went with Apache, as it was already installed on the server in question, thus reducing the complexity of the setup.

On Apache, you need to enable mod_proxy. The Apache SSL configuration looks like this:

<VirtualHost *:443>

    ProxyPreserveHost On

Open PHP stack trace links in PhpStorm

Inspired by a tweet from Wouter, i wanted to configure my setup to open stacktrace links directly in PhpStorm. Turned out there was more involved than i thought at first. Documentation is sparse and confusing, so i want to record the steps i needed here. Basically you need to configure xdebug.file_link_format and make your system handle a new protocol. Its less complicated than it sounds:

Configure XDebug

Just configure the xdebug extension in your php.ini to set
xdebug.file_link_format = pstorm://%f:%l

A colorful globe with the WS2801 LED strip

Looking for something nice that could be done with the WS2801 strips i bought, I came up with this idea to build a light globe. The arduino drives the strips and has a couple of programs it runs.

The best way to show how this all looks is probably some movies. (Beware, i used my cheap digicam to record, no high quality...). Some still pictures at the bottom.

The globe in action

Symfony2: Profiler trying to serialize objects or how to build your own router

The other day, i wanted to write a controller that expects an object as an action parameter, with the help of a custom router. Writing the router was as easy as adding a field to the array i return in the match() method. But then sometimes the controller has to send a redirection response. In production mode, everything works fine.
But in debug mode, i got a - very non-telling - error about serializing:

Notice: serialize(): "controller" returned as member variable from __sleep() but does not exist in
/home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php line 30

Symfony2 arrays as parameters in xml dependeny injection

Symfony documentation recommends to use XML for dependency injection configuration. I like the yml format because its simple and intuitive, but the main benefit of XML is the possibility for better validation and editing help.
So today we tried to port some configuration from yaml to xml.
Our yaml file contained an array parameter:

        en: [en, de]
        de: [de, en]

To make this work in XML, you need to nest parameter tags and use the type="collection" attribute.

    <parameter key="symfony_cmf_multilang_content.lang_preference" type="collection">
        <parameter key="en" type="collection">

Symfony2 controller as a service and the service_container

NOTE from 1.5 years later: This is not best practice. If you want a testable controller or write a reusable bundle, you should take the effort to inject the services you actually need, instead of extending the symfony base controller. For rapid development however, i would still recommend this as the base controller methods are very convenient.

I often want to have my controllers be a service so you can inject some information. But at the same time i like to extend the base controller Symfony\Bundle\FrameworkBundle\Controller\Controller to have the convenience methods like $this->render. Now if you just create a service from your controller, you won't be able to use the methods anymore. You will get exceptions about calling get() on a non-object.

Arduino and WS2801 RGB LED strip

Recently, i ordered a sample of a ws2801 based RGB LED strip from China. After todays successful playing around with it, I plan to order a bigger quantity beginning of next week.

A frontend editor for Symfony2 CMF with the help of VIE

I repost some of my blog posts made @ liip. Please see here for the original post and comments:

Yesterday we started working on an editor for the Symfony2 Content Management Editor, the LiipVieBundle. We use VIE and - until something non-GPL comes along - the Aloha editor. VIE is a piece of javascript on top of backbone.js that handles storing data with a REST backend. In Symfony2, this is a breeze thanks to the FOSRestBundle. Sounds complicated? Its actually quite simple, at least for the user. I made a short video to show how it looks.

Jackalope progress

I repost some of my blog posts made @ liip. Please see here for the original post and comments:

At Liip, employees can propose open source projects they want Liip to support. Together with Daniel Barsotti, I did this for the PHP Content Repository implementation Jackalope and Liip was so nice as to grant us a couple of man-weeks to implement stuff for Jackalope. Now that we used up the allocated budget, its time for a progress report what Jackalope can now do.

Syndicate content