Category: php
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!
mcrypt and PHP 5.3 on Ubuntu Jaunty
My dedicated server still runs on ubuntu jaunty. I wanted to move on to php 5.3 (php 5.2.16 was the final release of the php 5.2 series). The issue is: php 5.3 is not available in jaunty repositories, because it will stay at 5.2.
Installing php 5.3 was simple, just add to:
the following:
2
deb-src http://php53.dotdeb.org stable all
Install the dotdeb pgp key:
Update the apt cache and upgrade php5:
But when you want to install phpmyadmin again now, it fails.
Luckily you can get that (mcrypt) by adding the lenny updates repository manually:
add:
Install the debian gpg:
Now update again:
and install php5-mcrypt flawlessly:
I commented out the new sources.list entries after the install, because I don't need them to be checked on every update.
Configure an Agavi Site with NGINX (using PHP-FPM)
I was used to configure my Agavi site with Lighttpd and recently switched to Nginx. The setup for Nginx was not so common to me, so I decided to write down what I had to do to configure it properly. Here is an example for dracoblue.net. Please change the parts of the script to suit your needs (the necessary parts are highlighted with "HINT:").
First of all install php5-fpm. On ubuntu I did it this way:
Now create a new file:
And add the following:
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
listen dracoblue.net:80;
# HINT: Add the servername, so Agavi is able to see that it's dracoblue.net
# Otherwise you'll get something like "localhost" here
server_name dracoblue.net;
location / {
# HINT: The directory where index.php is
root /home/dracobluenet/tags/1.0.0/pub;
index index.php;
# HINT: All files except those in "static" should be served by index.php
location ~* ^/(favicon.ico|robots.txt|static) {
break;
}
# HINT: All files except those in "static" should be served by index.php
if ($uri !~ "^/(favicon.ico|robots.txt|static|index.php)") {
rewrite ^/([^?]*)$ /index.php?/$1 last;
}
}
location ~ \.php($|/) {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
# HINT: The directory where index.php is + $fastcgi_script_name
fastcgi_param SCRIPT_FILENAME /home/dracobluenet/tags/1.0.0/pub$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
}
As you can see, for projects I usually have only a "static" folder which is not served by agavi. This keeps the amount of work low, which nginx needs to do for each request to decide whether it should be served by php or not. I also added robots.txt and favicon.ico since you usually have them in root, too.
Restart nginx.
PhpDebugToolbar 1.1.1 (for agavi) released
Today I am pleased to announce the availability of the Agavi PHP DebugToolbar for download. After the success of the Qos-Filter for agavi, I want to relaunch the useful agavi toolbar with a different name, a better look and feel and a way better code base.
What is PhpDebugToolbar?
Like you can see on the screenshot, it's a little Toolbar (written in JS+CSS), which keeps track of all stuff happening in your php agavi application.
So you can easily spot memory leaks, time exhausting tasks and extensive usage of database queries (with the doctrine extension).
Additionally it integrates easily into the logging system of agavi, just add the PhpDebugToolbarLoggerAppender class in your logging.xml!
Where to download Toolbar?
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.1.1 (just 20KB) is also available here at dracoblue.net.
Short installation and configuration information can be found in the readme. Thanks to all contributors!
This is meant to be a lightweight alternative to the unofficial Agavi Debug Tools. It won't have FirePHP output or other neat features, which ship with Agavi Debug Tools. So if you need them: use adt, please!




