News

Refactoring the old FTP API usage

at 2009-06-30 in Examples by friebe

If you are running an XP release before 5.7.3 and are still using the old FTP API (e.g. FtpConnection::put(), FtpConnection::get(), etcetera), this will no longer work. These methods have been deprecated since October 2007 when RFC #0140 was implemented but have continued to work until recently. But as the FTP API has been rewritten and in this course these deprecated methods have been removed, now it's finally time to migrate!


(more)

Deadlock handling

at 2009-06-16 in ExamplesDatabasesRFCs by friebe

DeadlockThe changes implemented in RFC #1059 make handling deadlocks easier. During deadlocks you might want to your program behave differently than during "regular" statement failures. For example, in Sybase, all transactions, regardless of their nesting level, are rolled back during a deadlock!

You may have written sourcecode as follows in the past:

<?php 
try
{
// ...
} catch (SQLStatementFailedException $e) {
if
(1205 == $e->getErrorcode()) {
// Deadlock
}
}
?>
The problems should be obvious to the reader: The hardcoded errorcode (here the relevant one for Sybase), the very unelegant if, the missing portability for other drivers (PostgreSQL for example).


(more)

rdbms.DriverManager and supported connections

at 2009-06-09 in DatabasesAnnouncements by friebe

The rdbms.DriverManager class has been changed to only support drivers when the required extension is available. This changes fatal errors to exceptions in the following use-case:

<?php 
$conn= DriverManager::getConnection('mysql://localhost')->connect();
?>
Before (assuming ext/mysql is not loaded), this would print Fatal error: Call to undefined function mysql_connect(), now it raises an exception:
  Exception rdbms.DriverNotSupportedException (No driver registered for mysql
- is the library loaded?)
at rdbms.DriverManager::getConnection((0x11)'mysql://localhost') [...]
at ...


(more)

5.7.3-RELEASE: Doclet API, COM, New FTP API, Webservices revamp

at 2009-06-08 in ReleasesAnnouncements by friebe

The XP team is proud to announce the release of 5.7.3. This release again features numerous bugfixes but also quite a bit of improvements to the doclet command (see here, here and here), reflection for class constants, package mapping for client classes in the remote API, a completely rewritten FTP API and the new text.spelling package.

Continue reading...



Generating your own API documentation

at 2009-06-07 in Examples by friebe

ScreenshotTo generate api documentation for your project or library, a new project inside XP Forge has been started. It will - like the JavaDoc tool - generate documentation from apidoc comments inside your classes' sourcecode into browseable HTML pages. On the right hand side, you can see an example of the generated HTML.

Features:

  • A package overview pages shows interfaces, classes, enums, exceptions and errors summary
  • For interfaces, implementing classes are listed
  • For classes, all direct subclasses are shown
  • Markup in apidoc comments is recognized and displayed
  • The output is styleable via CSS

Note: To use this generator, you must be using an up-to-date source checkout of both xp framework and xp forge or wait for the upcoming 5.7.3 release which will include this.


(more)

XAR support in doclet command

at 2009-06-07 in Announcements by friebe

As mentioned in an earlier entry, the doclet command can be used - for example - to discover unittests in classes. While earlier on this only worked with classes residing in the filesystem the doclet API has now been extended to work with XAR files. To retrieve information about source files bundled in a XAR archive, use the sourcepath option:

  $ doclet -sp devel/xpadmin/trunk/releases/5.7.2/lib/xp-rt-5.7.2.xar doclet.Class [...]
This feature will be included in the upcoming release, 5.7.3..



Discovering unittests

at 2009-06-01 in UnittestsExamples by friebe

In the api documentation of a class, certain tags can be used, such as @see, @param or @return. Not only can they be used but it's actually strongly encouraged (you knew that, though).

To discover unittests by a given class name, the doclet API can be used.


(more)

FTP API Rewrite

at 2009-05-17 in Announcements by friebe

The old FTP API used PHP's ftp extension. This had limitations that expressed themselves when using the streaming capabilities:

<?php 
$file= $conn->rootDir()->getDir('htdocs')->getFile('index.html');
with
($stream= $file->getInputStream()); {
while
($stream->available()) {
Console::write
($stream->read());
}
}
?>

This code worked as expected but made the connection unusable thereafter. This was due to the fact that streaming requires using ftp_raw() commands and we needed to read two lines (150 opening XXX mode connection and 226 transfer complete), which is not supported. This messes up the internal state maintained in the implementation's stack.

Because FTP is a drop-dead simple protocol, current head now contains a complete rewrite of the FTP api to use pure sockets. At the same time, there is no longer a dependency on the ftp extension.



New package: text.spelling

at 2009-05-17 in Announcements by friebe

The new text.spelling package provides a wrapper around the pspell extension and provides an easy way to spell-check texts. Here's the basic usage:

<?php 
$spell= new SpellChecker('en');
$spell->check('Hello'); // TRUE
$spell->check('Bahnhof'); // FALSE
$spell->suggestionsFor('delibrate'); // [ "deliberate", "deliberator", "deliberated", ... ]
?>


(more)

XP Runners with CGI-PHP

at 2009-04-28 in Announcements by friebe

Using a dev-checkout, you can now use the XP runners using CGI-PHP (SAPI cgi-fcgi). This requires an update to the runners which can be accomplished as follows:

  $ cd ~/bin
$ wget 'http://releases.xp-framework.net/download/bin/setup' -O - | php
The new runners will be distributed along with the upcoming 5.7.3-RELEASE.



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