rss

Installing php apd on php 5.3.10

Today I wanted to extend the phpdebugtoolbar to allow tracing for good old mysql_query commands. This can be possible by using the rename_function-method, which is provided by the apd pecl extension.

It's a pitty that this extension cannot be compiled for php >= 5.3 without any patch.

So here the step by step guide to get it up and running on a php 5.3 or later.

1. Download apd-1.0.1.tar.gz from pecl.php.net.
2. Extract the files
3. Patch the code

1
2
3
4
5
6
7
8
9
10
11
12
diff --git a/php_apd.c b/php_apd.c
index 6707e02..8bfafb5 100644
--- a/php_apd.c
+++ b/php_apd.c
@@ -964,7 +964,7 @@ ZEND_DLEXPORT void onStatement(zend_op_array *op_array)
int apd_zend_startup(zend_extension *extension)
{
TSRMLS_FETCH();
- CG(extended_info) = 1; /* XXX: this is ridiculous */
+ CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
return zend_startup_module(&apd_module_entry);
}

4. Run phpize to configure the extension.
5. Run make to build the extension
6. Run sudo make install to copy the .so to the necessary location
7. Add this line to your php.ini (the folder may be different on your system)

1
zend_extension=/opt/local/lib/php/extensions/no-debug-non-zts-20090626/apd.so

That's it. If you receive the error message, that apd.so is not a valid extension, you must use "zend_extension=" and not "extension=" to configure the extension properly!

Call

1
2
3
4
5
$ php --version
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Advanced PHP Debugger (APD) v1.0.1, , by George Schlossnagle
with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans

and the Advanved PHP Debugger info appears.

In open source & php By DracoBlue @ 21:53 26.04.2012

Install pandoc 1.9 on ubuntu lucid/oneric

Don't install pandoc with apt-get. Follow those instructions to get the latest version,

You need haskell-platform. Don't install haskell with apt-get, too.

Use this guide how to install haskell on ubuntu.

As soon as you are done, you can install pandoc with this:

1
2
$ cabal update
$ cabal install pandoc

Remember to do this NOT with sudo, because you want to have cabal locally available with the current user.

But if it fails with:

1
2
3
Resolving dependencies...
cabal: dependencies conflict: base-3.0.3.2 requires syb ==0.1.0.2 however
syb-0.1.0.2 was excluded because json-0.5 requires syb >=0.3.3

you did accidently installed haskell-platform with apt-get. Do

1
$ sudo apt-get remove haskell-platform

and follow the link from the beginning of this post!

In Ubuntu By DracoBlue @ 22:44 10.03.2012

Assertions and No-Test-Framework in PHP

When I was writing the tests for Craur, I wanted to try a new way (no phpunit this time) to write tests in php.

Since php already has a assert($assertion) method, I imagined that it might be a good start to test without an extra test framework.

A simple

1
assert(false)

raised a warning. Nice! So I made the following approach:

1
2
3
tests/
my_test_file.php
another_test.php

Whenever I want to launch the tests, I just go into the tests folder and launch php $file_name for all of them. If the exit code is different to 0 -> the test failed.

It's a pitty, bit assert($assertion) does not raise an exception or something like this. Great for other use cases, but in mine this was really an issue. So I wrote this small wrapper script bootstrap_for_test.php. It registers a new AssertionException class for all kind of errors and as ASSERT_CALLBACK! Now even a notice or a warning make the test fail. Great!

Now a simple test looks like this:

1
2
3
<?php
include('./../bootstrap_for_test.php');
assert(2 == 3);

To have the tests run at once, I wrote a little run_test.sh script. It runs every test and returns the script with an exit code different to 0, if one of the tests fails.

All integrated with Travis CI and Craur is tested!

In open source & php By DracoBlue @ 11:29 05.03.2012

How I built a social game in one week: SwarmFight

It has been an interesting past month, so I want to share how I build a social game for desktop and mobile devices by using Javascript and HTML/CSS.

Since it took me 7 days to make it, I entitled the blog post: "How to create a social game in one week"! I will post all 7 days of my development diary now, so you can see what progress I made at which time and which issues evolved and got fixed :).

The game is an online realtime multiplayer puzzle game called **SwarmFight** and freely available to join at http://swarmfight.com.

In php, JavaScript, jQuery, JsBehaviour & SwarmFight By DracoBlue @ 20:44 12.02.2012

JSB 1.3.0 released - Good bye Inline-Javascript

Today I finally finished JSB 1.3.0. The JsBehavourToolkit is a little toolkit to avoid any inline javascript, allow copy-and-paste of behaviour on html elements.

There is a native version, which works without any framework from (Firefox 3+, Safari 5+, Opera, Chrome and IE9+). The jQuery and Mootools Version works with any browser (even IE6).

New in 1.3.0 is a simple (by design!) event system. It is framework independent and works with simple channel identifier and a json-object as value.

1
jsb.fireEvent('HoneyPot::CLICKED', {"name": "Bob", "times": 2});

This should be fired by a Js-Behaviour which needs to say something, instead of global variables and direct call. This enables you to use dependency injection if you keep the channel identifier the same.

You can listen to that event, too:

1
2
3
4
5
6
jsb.on(
'HoneyPot::CLICKED', // identifier
function(values) { // callback
alert('The user ' + values.name + ' clicked it already ' + values.times);
}
);

It's even possible to filter for a filter-object when listening:

1
2
3
4
5
6
7
jsb.on(
'HoneyPot::CLICKED', // identifier
{"name": "Bob"}, // filter everything with name = Bob
function(values) { // callback
alert('The user ' + values.name + ' clicked it already ' + values.times);
}
);

You may also use RegExp as channel identifier when calling jsb.on:

1
2
3
4
5
6
jsb.on(
/^HoneyPot.*$, // identifier which starts with HoneyPot*
function(values) { // callback
alert('The user ' + values.name + ' clicked it already ' + values.times);
}
);

Have fun with this release. Sourcecode is of course MIT-Licensed and available on github. Tests for jquery, mootols and native version are shipped in the tests-folder.

In open source, JavaScript, Mootools, jQuery & JsBehaviour By DracoBlue @ 11:45 04.01.2012

Spludo 1.1.0 released

Finally a new spludo 1.1.0 release is available. This is also the start of 1.2-dev development.

The 1.1-branch will stay to support node version 0.4, 1.2 will (soon) support only 0.6 and later.

Changes from 1.0.3 to 1.1.0:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
* added dependency to node >=0.4.0 && node < 0.5.0
* generator for monit+upstart configuration
* code generation for migrations extended with shortcut fields definition
* added support for application/json paylod
* generate *ByIds method for services
* added ApiServiceController to register a service as REST service
* context.request now holds the current req instance
* added inflection.js
* added node_modules for own vendor libraries
* replaced own testing system with vows (if you want to run the tests, please install vows!)
* spludo_directory variable is now set always when calling spludo-gen
* added bootstrap_manager.whenLoaded(callback) to get notified as
soon as the app is ready.
* replaced self with that
* fixed core_dev_change_build_version on MACOSX
* added jshint instead of jslint
* added support for node_modules folder in project directory
* added Criteria for DatabaseDrivers
* added code generation for Migrations
* added SqliteDatabaseDriver
* added a Database Migration system
* added MysqlDatabaseDriver
* added code generation for Services
* added DatabaseManager and ServiceManager
* added Logging#addTracing (makes the this.trace(function_name) obsolete)
* Codegeneration loads the spludo application now (this enables the developer
to generate code against the base of the application)
* Codegeneration #validateParameter receives the validated parameters now
* TestCases are now able to call .debug+.log and so on, because the execute
method is applied to the TestSuite.

I have been using this development version for plenty small projects and the code generation, migrations and database driver stuff should really help
you get your app developed way faster!

Loads of documentation and examples can be found in the spludo user guide.

Have fun!

In open source, node.JS & Spludo By DracoBlue @ 13:00 20.11.2011