Wednesday, 18 Jun 2008
So yesterday I spend a few hours writing out an RFC for ifsetor() (note that I put it into the “declined” section). While working through the discussion again, I realized that I had forgotten an important detail in the discussion: Currently we cannot provide a true COALESCE() implementation, which allows for any number of parameters. As such I totally forgot why people felt that the pass by reference hack was considered by these people as a viable approach. I also finally documented in detail why the addition of the shorthand ternary operator “?:” in PHP 5.3 is no replacement either.
(more…)
Popularity: 100% [?]
Tags: none
Thursday, 12 Jun 2008
Sorry guys, flamebait again. But i need to say this: I HATE NOTIFICATION FREE PROGRAMMING in PHP! If you want to code Java, go ahead! If you use PHP, enjoy the simplicity it brings! Today i found this code by someone who really wants to do it right:
$email = (key_exists(’email’, $values)) ? $values[’email’] : null; $password = (key_exists(’password’, $values)) ? $values[’password’] : null; $firstName = (key_exists(’firstname’, $values)) ? $values[’firstname’] : null; $secondName = (key_exists(’secondname’, $values)) ? $values[’secondname’] : null;
(more…)
Popularity: unranked [?]
Tags: none
Saturday, 7 Jun 2008
Earlier today I finished up work on the initial OAuth library. It has a few rough edges and missing features, but the bulk of the work for an OAuth Consumer is there. The rest is refactoring, feature iteration, and testing.
The new library is specifically targeted as a dual-proposal. It has been proposed to both PEAR and the Zend Framework. Rather than maintaining two distinct versions, or one distinct version with a heavy dose of abstraction, both are derived from the Zend Framework version. In essence, I develop primarily on the Zend Framework version, iterate patches onto a simple Phing task-chain, and out comes the PEAR version. This extends itself into the test suite too. This allows me to use the same base code, with changes appropriate to the underlying system (e.g. using PEAR HTTP_Request instead of ZF Zend_Http_Request). (more…)
Popularity: unranked [?]
21ef
Tags: none
Friday, 30 May 2008
I’ve spent some time over the last week, and I have completed an initial pass at writing an OAuth Consumer in PHP5. I’m biased, but it’s a nice chunk of code capable of fairly routine POST based OAuth requests using either an Authorized header, or a raw url encoded POST request body. My main remaining task is final cleanup, included refactoring, rolling my final set of acceptance tests into PHPUnit from SimpleTest, and adding support for HTTP GET, RSA, and a storage API so tokens can be saved in the background rather than outside the API.
I wrote up a quick example script using the current source code - bear in mind the final API will be tweaked but this is a close match for what I’d expect to become final (I’ll await community feedback before finalising anything!).
You can grab the code, which is geared up for integration into the Zend Framework as a Zend_Oauth component, from my proposals repository at http://svn.astrumfutura.org/zendframework/trunk/ (proposed components are in /trunk/library/Proposed). I fully expect to refactor a similar core library specifically for use with PEAR in the very near future.
Onwards with the example! I’m using the Ma.gnolia bookmarking service’s API (version 2) here. If you intend actually running the example, you will need to create a Ma.gnolia account and visit http://ma.gnolia.com/applications/new to register an application to get hold of an OAuth Consumer Key. Registering an application is a bit confusing - but basically create an imaginary one (e.g. “Super Duper OAuth Test Application”. Since you’ll be the only user for now, you can use it across any OAuth testing regardless of application name. In the code, replace CONSUMER_KEY and CONSUMER_KEY_SECRET strings with the real thing.
The example isn’t explained here - if you’re unfamiliar with OAuth I’ll explain it better in the future when this is all closer to completion. For now refer to the OAuth Core 1.0 Specification (the starting sections are pretty good at explaining things). The amount of code is indicative of features being wrapped around the existing API as they are not yet integrated directly (e.g. using Sessions to store temporary tokens instead of an internally referenced database). Also note that the example creates a new Access Key every single request (generally the annoyance of authorising yourself every time doesn’t exist in a completed solution
(more…)
Popularity: unranked [?]
Tags: none
Tuesday, 27 May 2008
I’m very happy to announce that memcache.php is commited to the CVS of pecl/memcache. Woot woot!
I’ll be maintaining the code through the time as well. Hope you guys/gals find it useful.
PS: I’m planning to add more functionality to the memcache.php in the coming days. Candidates:
Delete/Expire a cached value
Move stuff from server to server
Let me know if you have any other ideas.
Popularity: unranked [?]
Tags: none
Sunday, 25 May 2008

I will present both a tutorial and a regular session at year’s Zend/PHP Conference & Expo:
Tutorial: Quality Assurance in PHP Projects
Now that we know how to build applications that just work, are fast and scalable, as well as secure, the next logical step is to implement processes and use techniques that help us assure that the software works correctly throughout the softwares lifecycle.
(more…)
Popularity: unranked [?]
1f47
Tags: none
Friday, 23 May 2008
I have built a simple recommendation for one of the websites I work with. It is only based on social relationships and does not take into account other parameters. The basic idea is if I like an item, select other items liked by people who also like this item and it can be used to build lists of similar items as seen on Amazon or YouTube. If we use as an example people who like movies (tables Person, Movie and many-to-many relationship PersonMovie), this can be expressed in SQL using several joins:SELECT DISTINCT Movie.*, COUNT(Person.ID) AS PersonCount
FROM Movie
JOIN PersonMovie ON Movie.ID = PersonMovie.MovieID
JOIN Person ON PersonMovie.PersonID = Person.ID
JOIN PersonMovie AS PersonMovie1 ON Person.ID = PersonMovie1.PersonID
JOIN Movie AS Movie1 ON PersonMovie1.MovieID = Movie1.ID
WHERE Movie1.ID = 1 AND Movie.ID != Movie1.ID
GROUP BY Movie.ID
ORDER BY PersonCount DESCFirst we join movies to people and then backwards to the specific movie with ID = 1 that we want to get similar movies for. PersonCount is the relevance factor — the higher it is, the more people like the movie.The algorithm can also be implemented in PHP using Propel ORM, for example, as a method in the Movie class:public function getSimilarMovies(Criteria $c = null)
{
if ($c === null) $c = new Criteria();
elseif ($c instanceof Criteria) $c = clone $c;
MoviePeer::addSelectColumns($c);
$c-> (more…)
Popularity: unranked [?]
Tags: none
Monday, 19 May 2008
One of the most useful aspects of Integrated Development Environments (IDE), like Zend Studio or Eclipse PDT, is the ability to obtain code completion information when typing PHP source.
Regrettably, however, none of these IDEs is by default instrumented to provide code completion for PHP-GTK developers. But there is a way to make them seem PHP-GTK-aware.
read more
Popularity: unranked [?]
Tags: none
Sunday, 18 May 2008
I’m gonna attend NYPHP next Thuesday (Tuesday, June 24th at 6:30pm sharp) and look forward to meeting some folks from the NY PHP scene - is anyone else in the area and coming?
Their website tells me that Bruce Momjian (PostgreSQL core developer and EnterpriseDB Senior Database Architect ) will give a talk on PostgreSQL. Good enough to convince me to go, even though there will be the Facebook Developer Garage the very same day (good planning :P).
I might add that the meeting is at IBM’s offices in Midtown, and that you need to RSVP at least by Monday 3:00 PM.
(more…)
Popularity: unranked [?]
Tags: none
Friday, 16 May 2008
Recently noted by Derick Rethans in an informative blog post, there is (now was) a problem in the implementation of namespaces in the soon-to-be-released PHP 5.3. I quote:
Take for example this code:
In PHP 5.3 this would alias the class Interval in the namespace
PEAR::Date to the class Interval. For now, this code would work just
fine. However, if PHP would introduce a class “Interval” at
some point in the future (and PHP can do this as it owns the
global namespace) then the above code would suddenly stop working.
This morning, I realized that this would be very easy to fix, and posted a patch to internals@ with a brief explanation. Dmitry committed a fix to PHP_5_3 and HEAD very quickly. The issue raised by Derick is now obsolete, making namespaces not just more useful, but even more powerful than they were.
(more…)
Popularity: unranked [?]
Tags: none
|