Tags related to tag meditation
Wednesday, January 18. 2006
An issue with PHP's error handling
With all my REST and AJAX explorations, I have run into what I consider to be a fundamental issue in PHP's error handling: when the parser or interpreter runs into an error it will always return HTTP status code 200.
Semantically this is wrong. Here is the way it should be, at least in my eyes:
If PHP runs into a non-recoverable error (E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR and E_COMPILE_WARNING; i.e. where the error cannot be trapped by set_error_handler()), it should spit out a HTTP status code of 500 (Internal Server Error), and depending on the setting of the ini directive display_errors display the error text, or conversely the standard Internal Server Error page.
Currently, PHP just tells the user that everything is A-OK, when it most definitely isn't. That is wrong.
The next version of meditation will allow some kind of configuration so that PHP errors properly return a 500 status code, and display a friendly error message. It won't help with parse errors, core errors or compiler errors, but the semantics will be a little closer to on-target.
Update: Welcome new visitors! Meditation is a BSD Licensed REST API framework that facilitates in building your own REST API. It needs beta testers! It is available here.
If you are interested in any of my other PHP mumblings, check em out Here.
Semantically this is wrong. Here is the way it should be, at least in my eyes:
If PHP runs into a non-recoverable error (E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR and E_COMPILE_WARNING; i.e. where the error cannot be trapped by set_error_handler()), it should spit out a HTTP status code of 500 (Internal Server Error), and depending on the setting of the ini directive display_errors display the error text, or conversely the standard Internal Server Error page.
Currently, PHP just tells the user that everything is A-OK, when it most definitely isn't. That is wrong.
The next version of meditation will allow some kind of configuration so that PHP errors properly return a 500 status code, and display a friendly error message. It won't help with parse errors, core errors or compiler errors, but the semantics will be a little closer to on-target.
Update: Welcome new visitors! Meditation is a BSD Licensed REST API framework that facilitates in building your own REST API. It needs beta testers! It is available here.
If you are interested in any of my other PHP mumblings, check em out Here.
Monday, January 16. 2006
Meditation 0.3
Version 0.3 of meditation is out.
Changes are:
- Removed lilys goofy templating, and made it a little nicer.
- Made lotus deal with PUT and DELETE request variables better by urldecoding them.
- Various bugfixes.
Next version will include:
- A firming up of the RequestObject interface, hopefully to make it a little nicer, and maybe auto-magickally deal with path info.
The new release is available Here. Wiki documentation, as always is Here.
Changes are:
- Removed lilys goofy templating, and made it a little nicer.
- Made lotus deal with PUT and DELETE request variables better by urldecoding them.
- Various bugfixes.
Next version will include:
- A firming up of the RequestObject interface, hopefully to make it a little nicer, and maybe auto-magickally deal with path info.
The new release is available Here. Wiki documentation, as always is Here.
Thursday, January 12. 2006
Debugging Ajax
When debugging an Ajax application, especially one that is talking to a REST API, especially especially if that REST API is one of your own building.
I was getting this strange error in the JavaScript console, NS_ERROR_ILLEGAL_VALUE 80070057. Something about an uncaught exception. Well, the solution was to stop using AJAX, and get right down to brass tacks: Telnet is your friend.
telnet bunny.jonnay.net 80
Trying 142.179.114.225...
Connected to panda-ba.sanriowasteland.net.
Escape character is '^]'.
DELETE /projects/TileEditor/tiles/tile.php?tiles=43c75444b6253 HTTP/1.1
Host: bunny.jonnay.net
If you just send raw request headers through telnet, it makes it a bit easier to understand what is happening. I will bet however, that if you are getting the NS_ERROR_ILLEGAL_VALUE messages, it means that you have some errant back-end code, and your error messages are none too friendly.
Better error messages will be a feature in meditation 0.2
I was getting this strange error in the JavaScript console, NS_ERROR_ILLEGAL_VALUE 80070057. Something about an uncaught exception. Well, the solution was to stop using AJAX, and get right down to brass tacks: Telnet is your friend.
telnet bunny.jonnay.net 80
Trying 142.179.114.225...
Connected to panda-ba.sanriowasteland.net.
Escape character is '^]'.
DELETE /projects/TileEditor/tiles/tile.php?tiles=43c75444b6253 HTTP/1.1
Host: bunny.jonnay.net
If you just send raw request headers through telnet, it makes it a bit easier to understand what is happening. I will bet however, that if you are getting the NS_ERROR_ILLEGAL_VALUE messages, it means that you have some errant back-end code, and your error messages are none too friendly.
Better error messages will be a feature in meditation 0.2
Tuesday, January 10. 2006
Meditation: The PHP REST API Framework.
Last night I was able to put the finishing touches on Meditation, the PHP REST API Framework. This is a simple set of 2 classes to facilitate the building of RESTful PHP applications.
As I mentioned in a previous entry "The Third Taste... Not So much..", PHPs handling of the PUT and DELETE methods are lacking. This is where Meditation comes in.
With Meditation, you get an instance of the Lotus singleton, which is an object-wraper around the request. You give it some callbacks that handle the methods you need, and it handles most of the low-level grunt work for you. The documentation is all available on my wiki right here, and the Alpha release is available here.
There is another singleton, Lily, which is an object-wrapper around the response. Currently it just handles responding to Client errors (HTTP 4xx messages) and Server errors (HTTP 5xx message), but in the future, it will also handle 2xx and 3xx messages as well.
I'm eating my own dogfood and using this in my funky Tile Editor.
Update: meditation is now up to version 0.5.1. Please check the trackbacks to this entry for future versions.
As I mentioned in a previous entry "The Third Taste... Not So much..", PHPs handling of the PUT and DELETE methods are lacking. This is where Meditation comes in.
With Meditation, you get an instance of the Lotus singleton, which is an object-wraper around the request. You give it some callbacks that handle the methods you need, and it handles most of the low-level grunt work for you. The documentation is all available on my wiki right here, and the Alpha release is available here.
There is another singleton, Lily, which is an object-wrapper around the response. Currently it just handles responding to Client errors (HTTP 4xx messages) and Server errors (HTTP 5xx message), but in the future, it will also handle 2xx and 3xx messages as well.
I'm eating my own dogfood and using this in my funky Tile Editor.
Update: meditation is now up to version 0.5.1. Please check the trackbacks to this entry for future versions.
« previous page
(Page 2 of 2, totaling 11 entries)




