SkyLedger iPhone App UI Clone Tryout using Titanium
Continue reading в†’]]>
PHP replication plugin future: eventual consistent, eventual served from cache!
Going to San Francisco
This weekend, after Falsy Values, I will be flying to San Francisco for a couple of weeks. There are some conferences:
MeeGo Conference, May 23-25
Aloha Editor dev con, June 6-8
However, as there is quite some time between these two events, it would be interesting to meet cool people and/or projects. So if you’re in the area, drop me a note.
Symfony task “default” context
When creating Symfony 1.4 CLI tasks, I stumbled upon an error message:
The “default” context does not exist.
After searching some old forums, I found a solution. Before you access any Doctrine class, you mus first bootstrap your context correctly. Here is an example:
$config = ProjectConfiguration::getApplicationConfiguration(‘frontend’, ‘dev’, false);
sfContext::createInstance($config);
The application name and the environment can come from CLI options. More on Doctrine tasks (I could only find 1.2 equivalent):В http://www.symfony-project.org/cookbook/1_2/en/tasks
PHP@FrOSCon 2011 CFP running
propose your talks for this now, since the CFP will end on May 23rd.
Oracle at the Dutch PHP Conference & php|tek
I’m off to Amsterdam to talk at the Dutch PHP Conference. After that it’s on to Chicago for php|tek.
See you there!
Looking forward to php|tek 2011
It’s been a few months since I mentioned it, but php|tek 2011 is quickly closing in on us. I’ll be attending with several of my fellow Synacorians as well as giving two sessions, Accessing Web Resources with PHP and Creating Desktop Application with Titanium and PHP.
Synacor, the company I work for, is one of the sponsors for php|tek. Knowing how much we all enjoy these conferences, I encourage you to take a moment while you’re at php|tek and voice your appreciation to Synacor representatives. Also, if you’re in the market for a job, consider applying there to join me in working on cool stuff with smart people.
Lastly, consider placing this badge on your web site or blog to promote the conference.
I look forward to seeing you there.
Debugging PHPUnit Tests in NetBeans with XDebug
Every now and then you run into this weird situation in your code, where something that was supposed to zig is now zagging and it makes no sense whatsoever. For me this ends up happening in my unit tests since i’m not running everything in the browser everytime and since my tests usually run more scenarios then a regular browser run, that’s where the weird stuff happens.
So your obvious way out is to add a few var_dumps into the code and try to understand what is happening, if you are doing that: STOP!
Drop that mouse and step away from your keyboard, you should be debugging not adding code to the mix. So debugging in a browser is a piece of cake in most IDEs like NetBeans and Zend Studio and so forth, but debugging your tests that are running on the command line take a few more cards up your sleeve. So this is how i configured my NetBeans IDE and my PHPUnit tests to communicate and let me debug what happens inside that crazy world.
Configure your NetBeans Debugging configuration
This is very straight forward, go to Preferences > PHP and set the debug settings, namely the port and a session id. For example: port 9000 and Session ID netbeans-xdebug.
Tell Xdebug what you want it to do
This is done by adding a few settings in you php.ini or if you use additional ini files, I recommend you create a xdebug.ini. You need to configure a few things here, we want xdebug to have remote debugging always enabled and we want to configure the port and ide keys we used in netbeans as well as configuring the output to be “dbgp”. This is how it will look in you ini:
xdebug.idekey=netbeans-xdebug
xdebug.remote_enable= On
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
Make PHPUnit send stuff to NetBeans
So this is enough for you to do URL based debugging, but we want to debug our unit tests to pick up on those weird bugs with a easy to repeat script to lock down on it. For this to work you need to export a xdebug config variable in your local environment, so that XDebug kicks off the debugging based on this command line script. You will need to set XDEBUG_CONFIG to “idekey=netbeans-xdebug”, but setting it everytime is a nuisance, so my approach is to create a phpunit-debug file that can do this for me and allows me to kick off debugging by simply changing the executable. This is the content of this file:
export XDEBUG_CONFIG=”idekey=netbeans-xdebug”;
phpunit $@
Make NetBeans start a debug session and not open a browser window
One last thing is needed for things to run smoothly. When you click on debug in Netbeans the usual process is for it to open up a browser window and debug from there, but we don’t want that, so we need to tell it to not open a browser. This is done by accessing File > Project Properties > Run Configuration and clicking on the “Advanced” button, here you can select “Do no open a browser” and you are set.
Running Debugging
To start a debugging session you will need to follow these steps:
Click on “Debug Project” button. Now Netbeans will start waiting for a connection.
Go to command line and run phpunit-debug. Now debugging starts, if you selected “Stop on first line” phpunit file will be opened on your IDE, click play and you are off.
There you go. Now you are all set to debug your tests and understand better what is triggering that failure deep down inside your suite.
В© Rafael Dohms for Rafael Dohms, 2011. |
Permalink |
Truncated by Planet PHP, read more at the original (another 1089 bytes)
PHP can perform better than Node.js
My previous post about using Silex and AppServer-in-PHP similarly to ExpressJS generate quite a bit of interest. In the Hacker News thread there was a question about memory usage, and so I put the AppServer under siege. Memory usage stayed constant at:
13958 bergie 20 0 125m 10m 2136 S 1 0.6 0:00.28 php
13959 bergie 20 0 125m 10m 2136 S 1 0.6 0:00.31 php
Then I did the same Siege for the ExpressJS version:
14051 bergie В В 20 В 0 В 615m В 12m 4988 S В В 0 В 0.7 В 0:00.34 node
The PHP implementation served 3.80 requests per second, while the Node.js version served 3.79, both on 11″ MacBook Air with Ubuntu 11.04.
This trivial example isn’t obviously the big test of PHP app serving vs. Node.js, but at least I was surprised that PHP did better than Node here.
Oracle Tuxedo: A New way to Run PHP Applications
The Oracle Tuxedo team have posted an Oracle Tuxedo 11.1.1.2 Web
Application Server Demo for PHP. It is a VirtualBox VM so you can
immediately test it out. The free VM is available from OTN’s Pre-Built Developer VMs page.
Oracle Tuxedo provides a scalable and highly available mid tier
platform capable of managing and integrating heterogeneous
applications. This overview datasheet explains its capabilities: “Oracle
Tuxedo provides a service-oriented infrastructure for efficiently
routing, dispatching, and managing requests, events, and application
queues across system processes and application services”. A raft
of other material is on the Tuxedo landing page. There is also a new white paper on PHP being
reviewed at this very moment.
The VM uses Oracle Linux 5.6. It has PHP 5.3 and Oracle Tuxedo
11.1.1.2 installed and configured. The SALT and TSAM components of
Tuxedo are also available.
Tuxedo’s PHP support comes in the form of a new mod_tuxedo module
for Apache 2.2 (or Oracle HTTP Server). This handles all PHP scripts,
executing them using managed PHP processes. Existing applications can
run normally:
Tuxedo also lets PHP be exposed as a web service:
The tutorial manual provided inside the VM steps through using PHP
in both ways. The NetBeans IDE, Oracle Database XE and MySQL are
included on the VM to make it easier to carry out your own further
experiments with Tuxedo and PHP.
Tuxedo has been around for a long time and has an established
customer base. If you look at Oracle Database’s big TPC-C benchmark’s
you can see Tuxedo was involved. It’s even certified on Exalogic. The new dynamic language support in Tuxedo
is going to open up “Enterprise” infrastructure, making it easy to
integrate modern solutions in a heterogeneous environment.
When I get back from the Dutch PHP and PHP|Tek conferences, which
run back to back from next week, I plan to write up more details about
using Tuxedo and PHP.
