Article
0 comment

Webshop Entwicklung

Nachdem es in der letzten Zeit ja hier etwas “off-topic” zuging, wird es in der kommenden Zeit wieder vermehrt Artikel zum Thema Webdevelopment und speziell Oxid Webshops geben.

Zudem bin ich der Meinung, daß gerade hier der Westzipfel / Aachen ja eher etwas unterrepräsentiert ist, was Oxid-Knowhow bzw. seine Sichtbarkeit betrifft. Hinzu kommt, daß wir gerade ein tolles eigenes Oxid-Projekt in der Entwicklung haben, über das ich dann quasi im Laufe der Entwicklung berichten kann.

Den Anfang wird ein Artikel zur unaufwändigen Erstellung eines XML-Feeds für die Google Produktsuche machen. Ihr dürft gespannt sein! Natürlich freue ich mich auch auf Fragen, zu denen ich dann evtl. auch Postings schreiben kann. Wer also Fragen oder Ideen hat, möchte sich bitte melden :)

Article
0 comment

Mac App für Entwickler: qPHP

Heute möchte ich kurz eine kleine App meines Kollegen Dean Tomasevic vorstellen, die eine fantastische Hilfe bei der täglichen Arbeit mit PHP sein kann. qPHP ist ein kleines Tool, daß man im App Store erwerben kann.

qPHP_Browser

Das Tool besteht aus einem Fenster mit 2 Bereichen, einem Input-Feld in der oberen Hälfte und einem Output unten, dieser mit zwei Tabs für eine HTML gerenderte Ausgabe und als reiner Konsolentext.

qPHP_Code_Console

Zusätzlich gibt es natürlich einen “Execute” Knopf, der den Code ausführt und – besonders interessant – ein Dropdown zur Auswahl einer PHP Version. Momentan werden die Versionen PHP 5.3, 5.4 und 5.5 zur Verfügung gestellt. Das spannende ist: man muß die PHP Interpreter nicht selbst installieren, die kommen mit der App!

Anders als bei der App “Quick Programming” muß man keine PHP Processing Instructions (<?php und ?>) mit angeben, das weiß die App von selbst (was soll man auch sonst eingeben, wenn nicht PHP Code?). Man kann das aber doch machen, dann stellt die App das fest und ergänzt den Quellcode nicht intern um die Instructions. Dieser Automatismus ist sinnvoll, man kann nämlich auch mittels CMD-O ein beliebiges PHP-File öffnen und in der App ausführen. Und die enthalten ja nun meistens die PIs.

Sehr schön ist auch, daß das App-Fenster fast beliebig in Größe und Aufteilung zwischen den beiden Bereichen variierbar ist. Klingt normal, kann aber nicht jeder.

Alles in allen eine klare Kaufempfehlung für PHP Entwickler auf dem Mac!

Article
0 comment

Dereferencing deeply nested arrays with array_reduce

Sometimes you need to grab a value from a deeply nested array and you get a path description to that value as a string. For example you get a path as

$path = “A.B.C.D.X”;

which refers to a value in an array like this:

$param[‘A’][‘B’][‘C’][‘D’][‘X’] = “Dorky”;

Now you would like to get the value “Dorky” only by using the string description in $path. You need to get every indexing step as a string value by exploding the string at the “.” characters.

$patharray = explode(”.”, $path);

Then you need to go along this path in array form and dereference the $param array down to its value. You could do so with a foreach loop on the $path array. But you can do it more elegant using array_reduce.
Normally array_reduce iterates over an array and gathers (in any sense) information to sum it up in some single value. But you can also replace this “sum variable” by something else. For example by a dereferenced value of an array … you get a clue?
And since we don’t want to pollute our namespaces with callback functions, why not use the new PHP5.3 feature of anonymous functions?
Putting it all together leads to a one liner:

$value = array_reduce(explode(’.’, $str), function($v, $w) { return $v[$w]; }, $param);

To try it out here is the complete script:

<?php
$str=“A.B.C.D.X”;
$param[‘A’][‘B’][‘C’][‘D’][‘X’]=“Dorky”;
$value=array_reduce(explode(’.’, $str), function($v, $w) { return $v[$w]; }, $param);
print_r($value);
?>

Have fun!

Article
0 comment

Any sufficiently advanced technology is indistinguishable from magic

I just wanted to share some words about the technology used in building this site. After playing around with many different CMS and blog engines I decided to use ExpressionEngine (EE). This has several reasons:

  • Its built using PHP which allows me to put my hands as deep into the code as I want or need to accomplish a given goal.
  • I used EE to build several customer web sites, so there is a significant amount of knowledge about solving complex problems with EE.
  • EE is one of the most versatile blog engines I know since it allows you to create as many blog or channel streams as you like and use as many of them in one page template as needed.
  • EE in version 2 is completely rebuilt using the CodeIgniter framework. This leads to clean compact code and lots of possibilities to extend its functionality.
  • Its well documented. the learning curve is steep (you can do lots of new things in a short amount of time).

I also have a nearly complete blog engine written in Django in my “cool projects drawer” but you know fast such projects advance …