PHP5

Support for PHP 5.3.12 / 5.4.2

at 2012-05-04 in 5.8-SERIES5.9-SERIESPHP5 by friebe

PHP 5With the release of PHP 5.3.12 and PHP 5.4.2, the current 5.8-SERIES's supported PHP versions now include all of PHP 5.2.10 through PHP 5.4.2.

The 5.9-SERIES supports all PHP versions between PHP 5.3.0 and PHP 5.4.2.



Closures and "this"

at 2012-04-08 in PHP5Language by friebe

What does the following (plain PHP) do?

  class Lambda {
protected
$greeting= 'Hello';

protected
function greeter() {
return
function($who) { return $this->greeting.' '.$who; };
}

public
static function main($args) {
$l= new self();
$greeter= $l->greeter();
echo
$greeter($args[0] ?: 'World'), PHP_EOL;
}
}

Lambda::main
(array_slice($argv, 1));

Well, we'd say it should print Hello World. And that, indeed, is what it does when invoked with PHP 5.4.

Unfortunately, with PHP 5.3, this does not work (support for $this was first removed and then re-added again after a lengthy discussion on the php-internals mailing list). To make things , in other languages and platforms, things work even more differently. This is why we've started an RFC on this topic. Its goal is to define consistent behaviour over all platforms XP language runs on. For details, see here.



PHP 5.4 support

at 2012-02-26 in PHP5Announcements by friebe

PHP 5 LogoBack in October 2011 we announced preliminary support for PHP 5.4. There have been quite a bit of bugs discovered (and fixed) in PHP since, partially due to the XP Framework's core test suite. You can follow up on the details in this GitHub issue.

On Windows platforms, the official RC8 will fail, you have to use this binary provided as a fix for PHP bug #60879!



PHP Namespaces and the XP Framework

at 2012-01-06 in RFCsPHP5Examples5.9-SERIES by friebe

With the implementation of RFC #0222, we have added optional PHP namespaces support to the XP Framework. Optional means the XP Framework itself will neither depend on PHP 5.3 (still supporting PHP 5.2.10 upward at least for the 5.9-SERIES) nor will it change any of its classes to use them. That doesn't mean you can't use them, though:-)

Here's a quick-start guide:

  • PHP namespaces use the backslash (\). These translate 1:1 to the package separator in the XP Framework, the dot (.).
  • Classes with PHP namespaces, fully-qualified and non-qualified XP classes may be mixed in one project. The XP group recommends migrating complete packages.
  • Inside classes using PHP namespaces, other XP classes need to be either addressed by their absolute fully-qualified names (e.g. \lang\Object) or imported via the use statement by their fully-qualified names; uses() may not be used there.
  • Inside classes not using PHP namespaces, namespaced classes must be added to the uses() list and addressed in their namespaced version.

As an example, if we have the following in de/thekid/tools/SQL.class.php:
  namespace de\thekid\tools;
use rdbms\DriverManager;

class SQL extends \lang\Object {
public
static function main(array $args) {
$conn= DriverManager::getConnection($args[0]);
// ...
}
}
To run this class, use xp de.thekid.tools.SQL ... as you would with a non-namespaced class.



RFC #0222: Optional support for PHP 5.3 namespaces

at 2011-12-23 in 5.9-SERIESPHP5RFCs by friebe

Scope of Change
Support for writing and using classes within PHP 5.3 namespaces will be added to the XP Framework's core. Because PHP namespaces are only available with PHP >= 5.3.0, support will be optional - using XP with PHP 5.2.x just will not offer the feature.

Rationale
Add benefit of using namespaces in classes. Namespaces allow reusing class names in a separate context, removing the need of class name prefixes and thus increasing overall code readability.

Read the full RFC here



TDS Protocol implementation

at 2011-12-23 in PHP5EditorialDatabases by friebe

One of the XP Framework's strategies is to keep compatibility over a large number of PHP versions on multiple platforms. For example, the message digest API contains a workaround for certain PHP versions with a broken CRC32b implementation, hiding it transparently from the user. In other places like the lang.Process class, we take care of platform differences, employing OS and feature detection, and even compensating for some implementation vagaries. Constructs like this can be found in various other places in our code base, and while this is definitely not desirable, it at least saves the user from going through this hell, and this way, we support the full range of PHP 5.2.10 through 5.3.8 (inofficially 5.2.0 - 5.5.0-dev also works) on a variety of Windows and Un*x systems.

Following this strategy, we go as far as rewriting functionality previously available through a PHP extension to userland implementations: The FTP API (because of limitations in streaming support), the parse_url() function rewrite to work around behaviour changes, userland ini file parsing to support Unicode, a reimplemented MD5-crypt to compensate for a critical bug in crypt() in PHP 5.3.7 and our own MySQL protocol implementation to be able to support old MySQL 4.x instances, to name only a few cases.

The TDS protocol implementation supporting connectivity with Microsoft SQL Server and Sybase database servers is the most recent addition to this stack. Though not yet completely finished, we expect to be able to add it to one of the upcoming 5.8 releases.



Preliminary PHP 5.4 support added

at 2011-10-30 in PHP5AnnouncementsHomepage by friebe

PHP 5 LogoWith a couple of forward-compatible tweaks, workarounds for PHP bug #60167 and PHP bug #60169 and some test refactoring to account for magic quotes deprecation, the XP Framework now runs with the current PHP 5.4 beta release.

You can read about the details here or just jump directly to the diff if you're interested in what was necessary on the code-level.

Please note that we'll have to wait for the real PHP 5.4 release until we officially support it.



PHP 5.3.2 support

at 2010-03-09 in 5.8-SERIESPHP5 by friebe

Following the PHP 5.3.2 release a couple of days ago we now officially support this new PHP version with the upcoming XP 5.7.8-RELEASE. Also tested successfully: The 5.8 development branch.



XP Framework & APC

at 2010-01-24 in PHP5 by friebe

Recently, I got an email from Jan, who has to websites running the XP Framework and who had upgraded his PHP to 5.2.12, asking for assistance with these sites being disfunctional and the following extracts from the web server's error log:

  [Sun Jan 17 12:46:43 2010] [error] PHP Fatal error:  Interface 'Generic' not found
[Sun Jan 17 12:37:34 2010] [error] PHP Fatal error: Allowed memory size ... exhausted

After some research work we found out the problem wasn't caused by the new PHP version but instead by the APC extension he had installed. We can reproduce this problem even on the command line, and it seems to be related to PECL bug #16860. The workarounds suggested in this bug that work for some only relieve these problems partially, although a simple site then works the XP core unittests show that there are still problems.

The XP Framework team suggests not to use APC with the XP Framework for the time being.



PHP 5.3.1 Released

at 2009-11-20 in PHP5 by friebe

PHP 5The PHP team announced PHP 5.3.1 yesterday wich fixes several security related issues and crashes. Due to all the forward and backward compatibility workarounds and ajdustments the XP Framework offers, we can now extend our version compatibility for the 5.7 series from PHP 5.2.0 - 5.3.1 (including all versions inbetween).



Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases
5.8-SERIES
Unicode
Language
5.9-SERIES