Danne on May 31st, 2009

I have been working on some really fun PHP projects with some really cool people the last six months. This has kept me busy both day and night so, naturally, blogging have not been a major priority. After creating a new Spanish photo sharing site fotos.es which took a few months we started on a Swedish project. And now, we are finally launching the best Swedish weather site, klart.se. As weather is what Swedish people talk about whenever they meet, a quality Swedish weather site is needed ;)

Even though all the project members are located in many different locations in both Sweden and Spain most things have gone really well.

After having been in Spain for the last six months it looks like it’s time to move on. In a few weeks we’re probably moving to Kalmar, Sweden. We haven’t lived in those parts since we moved to Dublin in 2000 and even though I really enjoyed my time here in Spain I am a looking forward to moving back home.

Tags:

I hade some time over and updated one of my own projects to Zend Framework 1.8.1. Apart from a change in the auto loader API everything went smooth. But I was a bit annoyed to find out that a simple translation bug still was unfixed. As my project is going live soon I need that bit fixed.

The bug is known and open so I didn’t need to report it. I voted for the issue to be fixed, waited two minutes and still no fix… I thought that was how open source projects worked ;)

Seriously though, I fixed the issue locally and added what I think should be a correct fix in the comments. (Even though I think it is weird that the transfer adapter should even have the remotest connection to translation logic.)

http://framework.zend.com/issues/browse/ZF-6647

Looking at the statistics for Zend Framework issues I think it is time to step back and slow down on implementing new features. The diff between new issues and resolved issues is constantly getting bigger and bigger while the average time to fix an issue is getting longer and longer. This is natural as the project constantly have grown since it’s birth. But as I like working with ZF I’d hate to see it become a big and unruly behemoth that adds more problems than solutions.

Tags: , ,

Danne on April 1st, 2009

Last night I spent a couple of hours with Zend Framework and especially Zend_Form. I discovered, and now also reported as ZF-6175, a bug in Zend_Validate_Float when using a locale with a decimal point other than “.”. There are unit tests but none that test Zend_Validate_Float under a different locale.

It is important to know that floats are actually locale aware in PHP. I’m not sure if that have always been the case. The below code will actually output 10,5 as Swedish use “,” as decimal point.

setlocale(LC_ALL, 'sv_SE.UTF-8');
echo 10.5;

The test in Zend_Validate_Float looked like

$locale = localeconv();

$valueFiltered = str_replace($locale['thousands_sep'], '', $valueString);
$valueFiltered = str_replace($locale['decimal_point'], '.', $valueFiltered);

if (strval(floatval($valueFiltered)) != $valueFiltered) {
  $this->_error();
  return false;
}

Under the Swedish locale mentioned above this will result in a comparison between two strings; “10,5″ and “10.5″.

I have proposed the following solution.

$locale = localeconv();

$valueFiltered = str_replace($locale['thousands_sep'], '', $valueString);
$valueFiltered = str_replace($locale['decimal_point'], '.', $valueFiltered);

list($num, $dec) = explode('.', $valueFiltered);
if (strval(intval($num)) != $num || strval(intval($dec)) != $dec) {
  $this->_error();
  return false;
}

But I just realized that it can be further simplified.

$locale = localeconv();

$valueFiltered = str_replace($locale['thousands_sep'], '', $valueString);

list($num, $dec) = explode($locale['decimal_point'], $valueFiltered);
if (strval(intval($num)) != $num || strval(intval($dec)) != $dec) {
  $this->_error();
  return false;
}

Tags: , ,

Danne on March 17th, 2009

There are probably as many solutions to creating SEO friendly urls as there are actual implementations. After real work yesterday I started looking at the rather simple method based on the PHP built in strtr() we use. It’s very simple and apart from some uppercase, lowercase and utf8 juggling the (very shortened) basis is something like below.

$isochars = "\xFC\xFD\xFF";
$asciichars = "uyy";
$urlfriendly = strtr($actual_string, $isochars, $asciichars);

What struck me was that the character þ (FE in hex) was translated into y. As is correct if you look at how y, in different forms, was used as an abbreviation for the, that and so on in old English - or Anglo-Saxon. Often it is now written “Ye” as in the blog post title. (Yes - the “Y” in the title should be pronounced as “th“.

However, it is a bit odd as the Icelandic language still use the letter frequently. The sound value is more or less the equivalent of the English “th” in this or the.

The major value in SEO friendly urls is the readability. Shouldn’t it be more friendly and natural to translate þ into “th” in SEO friendly urls then?

Tags: , ,

Danne on January 25th, 2009

As mentioned earlier I moved with my family from Sweden to Spain for awhile. To complicate things further me and my girlfriend Malin created a new company called Dotvoid AB focusing on web sites and applications based on PHP. (So expect things to change around here in 2009 - though no timeplan or schedule exists). I have also quit working with debt collection software and is now working full time on Spanish consumer web sites for Grupo Inico.

Conferences? Apart from the usual PHP conferences that might or mightn’t (!?) be of interest there’s a score of other events focusing less on technology and more on softer issues. An hour ago I received an email from the Ning group Swedish Startups with lots of interesting conferences. I probably won’t be able to attend many of those. But Future of Web Apps in Dublin really caught my attention. A not too expensive one day event with lots of cool people and companies. Not to mention a good reason to visit the city I lived in almost eight years ago. (At the time I was working as a contractor on a then cool project.)

Tags: , ,

Danne on January 19th, 2009

I have been away from blogging awhile. Life has been really busy lately and I have sold my house and moved, with my family, to Fuengirola in Spain. Hopefully now that daily life is again back to normal I’ll blog a bit more. Maybe I’ll talk a bit more about daemons, asynchronous I/O and CodeIgniter as my current contract includes those topics.


View Larger Map

Tags: , , ,

Danne on November 28th, 2008

As it is nearing Christmas I started thinking about things I would like to see in the PHP world. I don’t have time to write down a long wishlist but a few things would make me a happier person.

  1. Faster Eclipse/PDT/Zend IDE
  2. Builtin, reliable, refactoring support in PDT
  3. A good (good === simple and extensive) tutorial on using Zend_Test for testing applications built on Zend Framework - cause I’m starting to feel stupid here.

Apart from those three PHP specific wishes I also wish for all the usual stuff; a new mobile (I’ll buy one myself soon), more spare time with my family and friends (I’ll get that soon as well), world peace (tough one unfortunately), new laptop (my currrent - almost new - Dell sucks) and more.

I will get more free time soon. I’m selling the house in southern Sweden and moving with my family to southern Spain where I will work as a contractor for major Spanish consumer sites. Fun PHP work ahead!

Danne on November 21st, 2008

Yesterday we had the first OpenCoffee in Karlskrona at the new place Bistro Java. The initiative came from Martin and Christian at Svensk Webbutveckling. Really nice guys even though they seem to prefer strongly typed languages over PHP. We had a good chat about both business and web development in general as well as technology and languages.

Unfortunately we three were the only ones showing up so the event will be repeated next thursday. If you are interested in business, technology, internet and web development - and are nearby - drop in!

Tags:

Danne on November 10th, 2008

Last week we launched a new beta of our Swedish TV guide. It used to be based on Zend Framework 1.0 and has now been completely rewritten and upgraded to version 1.6.2. We didn’t seem to have any difficulties moving from 1.5 to  1.6 during development.

The framework is getting better and better even though I probably never will use things like the form builder functionality. One should never say never. But it seems backwards to me and I think it makes it more difficult to produce more advanced user friendly form based applications. Maybe I should force myself to use it a few times so that I can have a better opinion on it. Maybe…

Anyways, I’m more than happy with the first few days.

TV-rutan Statistics
TV-rutan Statistics

Tags: ,

Danne on October 31st, 2008

Handling SOAP structures in PHP can sometimes be really annoying. If an interface is defined in the WSDL as returning an array I can’t be sure that I will get an array. If there is only one element in the array PHP tries to be clever and turn the wanted array into an object which, too me, isn’t really smart. I don’t know if this is a problem/limitation on the client side, server side or if it is just me doing something stupid in the wsdl.

As an example I have the below complex types, message and operation defined in the WSDL file. (The example is not complete of course.)

    <complexType name="KeyValueData">
      <sequence>
        <element minOccurs="1" maxOccurs="1" name="id" type="string"/>
        <element minOccurs="1" maxOccurs="1" name="name" type="string"/>
        <element minOccurs="1" maxOccurs="1" name="data" type="string"/>
      </sequence>
    </complexType>

    <complexType name="ArrayOfKeyValueData">
      <sequence>
        <element minOccurs="0" maxOccurs="unbounded"
                 name="keyval" type="tns:KeyValueData"/>
      </sequence>
    </complexType>
      ...
    <message name="StatisticsListOutput">
      <part name="data" element="tns:ArrayOfKeyValueData"/>
    </message>
      ...
    <operation name="getStatistics">
      <input message="tns:StatisticsListInput"/>
      <output message="tns:StatisticsListOutput"/>
    </operation>

Sending this from the client is an absolute no brainer. It is a simple array containg associative arrays in every slot. When receiving this structure on the client side the original array (the member variable Map in the example) with one element turns into

Class Object
(
    [Map] => stdClass Object
        (
            [item] => Array
                (
                    [0] => stdClass Object
                        (
                            [key] => id
                            [value] => value
                        )

                    [1] => stdClass Object
                        (
                            [key] => name
                            [value] => value
                        )

where an array with multiple elements turn into

stdClass Object
(
    [Map] => Array
        (
            [0] => stdClass Object
                (
                    [item] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [key] => id
                                    [value] => value
                                )

                            [1] => stdClass Object
                                (
                                    [key] => name
                                    [value] => value
                                )

This is annoying. Just imagine the situation when you have multiple arrays in arrays… Which actually does happen every once in a while when sending compounds of various elements declared as ComplexTypes in the WSDL.

Is it a feature, quirk or anti social behaviour? I don’t know. If there is another way I’d like to hear about it.

Tags: , , ,