Category: php
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
2
3
4
5
6
7
8
9
10
11
12
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)
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
2
3
4
5
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.
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
raised a warning. Nice! So I made the following approach:
2
3
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:
2
3
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!
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.
Remote logging with rsyslog, php and agavi
When I tried to get rsyslog running with php I didn't face much problems. Anyways I want to share some things I noticed while getting it to work.
First of all ubuntu uses rsyslog already. Just a simple
and all syslog messages went directly into the database "syslog". Configure /etc/rsyslog.d/mysql.conf to insert this information into a remote machine.
Now let's get to php. You have the option to set:
This however does log all messages with
If you want to replace "php" with a custom message, you have to call
before any error happens. Because LOG_ODELAY is given, it won't connect to syslog unless any error happens, so one should be save to put this call at the top of your dispatcher file.
The final log message will look like that (254 is the process id):
Finally I wanted to log all messages created by agavi's logging system. Since I didn't found an existing AgaviSyslogLoggerAppender, I wrote one and put it up on a github-gist.
Have fun logging!
Installing php 5.3.5/5.3.6 on Ubuntu Maverick/Lucid
Latest Version for PHP 5.3 on Ubuntu is just PHP 5.3.3. This is not so good, if you want to have some of the plenty bugfixes which will be shipped with a later version.
If you want to upgrade to 5.3.5 (5.3.6 support may come later), you can use this inofficial ppa by the nginx user at launchpad: https://launchpad.net/~nginx/+archive/php5.
For ubuntu maverick just create a file:
with the contents
2
3
deb-src http://ppa.launchpad.net/nginx/php5/ubuntu maverick main
and run:
2
$ sudo apt-get dist-upgrade
Now you have php-5.3.5 installed on your ubuntu box! Have fun.
PhpDebugToolbar 1.3.0 (for agavi) released
Today I am pleased to announce the new version 1.3.0 of the Agavi PHP DebugToolbar for download.
New features include full propel support (thanks tim), rows+time+memory display for the database queries and some small bugfixes.
The source can be found on github now http://github.com/DracoBlue/PhpDebugToolbar, feel free to fork it and send pull request with new features!
Download for PhpDebugToolbar 1.3.0 (just 23KB) is also available here at dracoblue.net.
Short installation and configuration information can be found in the readme. Thanks to all contributors!


