Smarty v.3 preg_match plugin

I wrote a plugin for Smarty which allows to use the php preg_match function inside a template:

Usage:

  1. Copy the plugin in Smarty/plugins/function.preg_match.php
  2. In the template use the following code
{$haystack="cow,dog,niddle"}
{if {preg_match pattern="niddle" subject=$haystack}}
  {$matches|print_r}
{/if}

(more…)

How to make CI2 work with HMVC and SPARKS

I had the need to use both HMVC and SPARKS in a project but I found out that the instructions in the official guide are not working in all the conditions.

So I figure out what was wrong (hopefully!) and I ended up with two patched files which are now part of the RestIgniter-hmvc project and available for download.

Put these two files in application/third_party/MX/ overwriting the existant ones:

Loader.php

Modules.php

All the other steps shown it the spark guide are fine.

CodeIgniter 2.0.x – random notes

Quick and dirty notes about Code Igniter

CI Sparks: a package management system for Codeigniter that will allow you install high-quality libraries into your applications instantly.

XMLRPC vs REST vs SOAP vs CIM vs RMI vs Message Bus vs … Lots of RPC Options

What’s new in php  5.3.2

  • http://www.sitepoint.com/whats-new-php-5-3/
  • http://blog.felho.hu/whats-new-in-php-53-part-1-namespaces.html

Phpunit test

fooStack: CIUnit: Unit testing for CodeIgniter was famous for CI1xx but can’t be used on CI 2.0.x

stack overflow thread about phpunit for CI2

unit testing embedded in CI2

Improved CodeIgniter Unit Testing

Xdebug config file for Eclipse and php

Some time ago I spent a good amount of time learning xdebug in details and to make a good configuration file for it.

Of course, as it always happens,  I FORGOT about that … good job Dam! So this time I’m going to write down something in the hope that this will last longer in my mind… (yeah yeah I don’t believe myself too … )

In these days I was debugging Contact Engine and running tests. Tests are all made in this way:

a test makes a REST call to the server (just another php file of the same project), then the REST server does its job and the response goes back to the test code.

The issue was about break-points: setting a break-point in the REST server code didn’t stop the execution and so whatever happened in the REST “area” was unknown (shadow area) and so I just had to deal with the result provided by REST. At the beginning I thought it was correct because it’s another HTTP request to another page …. but I remembered that in another occasion (several months ago) it was working smoothly.

So I went in “stubborn mode” (i.e. rediscovering the wheel … ) and finally I found  a way to make it working and to be capable to put break-points even in the shadow area. Using this setting:

(more…)

Get status from Twitter

A very simple function to get your last post from Twitter

function getTwitterStatus() {
$username = 'your-username';
$url = 'http://twitter.com/statuses/user_timeline/'.$username.'.xml?count=1';
$xml = simplexml_load_string(file_get_contents($url));
$item = $xml->status;
$twit = $item->text;
echo $twit;
}