ExamplesPHP Namespaces and the XP Frameworkat 2012-01-06 in RFCs, PHP5, Examples, 5.9-SERIES by friebeWith 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:
As an example, if we have the following in de/thekid/tools/SQL.class.php: namespace de\thekid\tools;To run this class, use xp de.thekid.tools.SQL ... as you would with a non-namespaced class. Available database driversat 2011-01-16 in Databases, Examples by friebeHere's how to find out which database drivers are available (keys) - and what classes they're implemented by (values): Console::writeLine(DriverManager::getInstance()->drivers);This will yield, depending on the PHP installation and configuration, something along the lines of: [ mysql => lang.XPClass<rdbms.mysql.MySQLConnection> pgsql => lang.XPClass<rdbms.pgsql.PostgreSQLConnection> sqlite => lang.XPClass<rdbms.sqlite.SQLiteConnection> ] ZIP files now support Unicode filenamesat 2011-01-16 in Unicode, Examples by friebeThe XP Framework's io.archive.zip package allows reading and creating ZIP files and is tested against zip archives created by Info-ZIP 3.0, PHP's Zip class, 7-zip, WinRAR and Windows' "compressed folders". In SVN head, we have made a couple of adjustments to be able to support files written by Java's java.util.zip package (which is internally used by the jar command):
The new lang.Closeable interface and ARM blocksat 2010-12-31 in Language, Examples, 5.8-SERIES by friebeThe new lang.Closeable interface and the io.streams classes being retrofitted to implement it may not seem very useful on the first glance, although they serve the purpose of supporting the so-called ARM blocks. These are a feature supported by XP Language and reuse the try keyword: try ($expression[, $expression[, ...]]) { Any of the expressions are expected to be instanceof lang.Closeable and their close() methods are guaranteed to be called in the declaration order regardless of whether the block raises an exception or not. (more) Hudson and the xml.meta APIat 2010-12-30 in Examples by friebe I'm currently working on a Hudson remoting API to be able to remotely configure our continuous integration projects. An example usecase occurred today: A co-worker had created a Hudson plugin which helps us distinguish projects with no tests at all from projects with tests exist: It display a different icon in the "weather" column and sets the build status to unstable. Now what we want to do is to enable this plugins in all projects, which would mean clicking through an odyssee of "Select Project - Configure - Enable - Save" more than 70 times in the frontend.Hudson contains a Remote API which should be able to tackle this job. (more) apt-get meets the XP-Frameworkat 2010-12-16 in Examples, Editorial by friebe The XP Framework has an easy-to-use installation mechanism - simply downloading a setup script and piping it directly to PHP. What this mechanism cannot do though is to install PHP as a dependency itself, which is usually done in an operating-system dependant manner. On Debian and Ubuntu distributions, the packaging mechanism is called APT (Advanced Packaging Tool), which installs Debian packages (.deb files). In order to build such a package, we need to create a control file as well as the intended directory structure and wrap all that up using the "dpkg" tool (there's a howto over at IBM's developerworks). Unfortunately, this approach requires the Debian packaging tools to be available for the build platform - a situation we cannot rely on. This article shows a solution written in the XP Framework.(more) XP: Log SQL queriesat 2010-10-18 in Examples, Databases by friebeReading PHP: 62 characters to see all MySQL queries, I thought I'd post a similar use case solution here. The task is to log all SQL queries and a backtrace of where they're executed from. In Ulf's post, this is accomplished by an extension function written in C, which needs to be compiled and loaded into PHP. Altough a nice feature, this way has several downsides, first of all, the compilation, a hurdle big enough to keep me from trying it out, and second, it's only going to work with MySQL databases (and to be precise, only those newer than 4.0, because mysqlnd doesn't support MySQL's old password protocol handshake). (more) First steps with the XP Languageat 2010-09-24 in Language, Examples by friebeThe XP language is not completely different from the way PHP works, it keeps the flexibility and the general "look and feel" while adding syntactical support for features PHP doesn't support or doesn't support in all versions the XP Framework runs on. Like in the XP framework, the entry point is always a class. In their most simple form, these classes have a static main() method. An example: public class HelloWorld {OK, this doesn't look too unfamiliar, does it? (more) 5.8 Feature showcase: Accessing class internaat 2010-08-30 in Examples, 5.8-SERIES by friebe The XP Framework's 5.8-SERIES contains a feature that will allow the reflection API to access private and protected members. Of course, just because you can, doesn't mean you should, as this does allow you to break the encapsulation principle.On the other side, this feature comes in handy for serialization mechanisms, as well as for reflection-based factory or delegation patterns. (more) Generics of primitivesat 2010-08-10 in Examples, 5.8-SERIES by friebeLike in C# (and unlike Java), primitives can be used as components of generics in the 5.8-SERIES. Given a vector util.collections.Vector<string>, the following applies: // OK Primitives can also be used in other generic collections types, e.g. Set and Map implementations as well as Stack and Queue. |
|