Feeds

Get your PHP on the right Trax

Framework flattery

Secure remote control for conventional and virtual desktops

Hands on Ruby on Rails has become a popular framework for developing database-based web applications using the Model-View-Controller (MVC) pattern.

Before Ruby on Rails, though, PHP was hogging the web-development limelight. Problem was, there was no Model-View-Controller (MVC) framework for PHP.

With Ruby on Rails, though, PHP developers have come to realize the timesaving benefits of MVC - a fact that led to the development of various PHP frameworks that are actually based on Ruby on Rails.

Among them, the Akelos framework and PHP On Trax.

In this article we shall develop an MVC Create-Read-Update-Delete (CRUD) application using the PHP On Trax Framework. Why this particular framework? Simple: it is a direct port of the Ruby on Rails framework.

Install PHP On Trax

Install Apache HTTP Server 2.2 in C:/Apache directory and PHP 5.2 in C:/PHP directory, and configure the Apache server with PHP. Install a MySQL 5.0/6.0 database and enable the MySQL extension in the php.ini configuration file. by removing the ';' from the following line:

extension=php_mysql.dll

Set the extension_dir directive in php.ini to the directory containing the extensions.

extension_dir = "./ext"

Set error reporting in php.ini file to E_ERROR.

error_reporting  =  E_ERROR

We also need to install the MDB2 driver for MySQL, which is available as a PHP Extension and Application Repository (PEAR) module. First, install PEAR if not already installed. Download go-pear.php and run the following command to install PEAR:

C:/PHP>PHP go-pear.php

Download the MDB2 driver for MySQL Copy the .tar file to the C:/PHP directory. Install the MDB2 driver with the following command:

C:/PHP>pear install -o MDB2_Driver_mysql-1.4.1.tar

PHP On Trax is available as a PEAR module. Run the following commands to install PHP On Trax:

>pear channel-discover pear.phpontrax.com
>pear install trax/PHPonTrax

A PHP on Trax directory gets created in the C:\PHP\PEAR directory. Create a trax.bat file in the C:/PHP directory, which is in the PATH environment variable. To the trax.bat file add the following code:

php C:\PHP\PEAR\PHPonTrax\trax.php %1

Add the .phtml type to the httpd.conf file to render the .phtml view templates.

AddType application/x-httpd-php .php .phtml

The .phtml view templates contain a short form of PHP's open tags. Enable the short open tags in php.ini file.

short_open_tag = On

Start your build

In this section we create a PHP on Trax application. The MVC application shall be used to create, read, update and delete catalog entries in a database table. Create an application catalog in the Apache web server root using trax.bat with the following command:

C:\Apache\htdocs >trax catalog

A trax application with an application structure similar to a Ruby on Rails application gets created. The app directory consists of the controllers directory for the controller PHP scripts, the models directory for the model scripts and the views directory for the view templates.

Top 5 reasons to deploy VMware with Tegile

Next page: Reboot time

More from The Register

next story
New 'Cosmos' browser surfs the net by TXT alone
No data plan? No WiFi? No worries ... except sluggish download speed
iOS 8 release: WebGL now runs everywhere. Hurrah for 3D graphics!
HTML 5's pretty neat ... when your browser supports it
Mathematica hits the Web
Wolfram embraces the cloud, promies private cloud cut of its number-cruncher
Mozilla shutters Labs, tells nobody it's been dead for five months
Staffer's blog reveals all as projects languish on GitHub
'People have forgotten just how late the first iPhone arrived ...'
Plus: 'Google's IDEALISM is an injudicious justification for inappropriate biz practices'
SUSE Linux owner Attachmate gobbled by Micro Focus for $2.3bn
Merger will lead to mainframe and COBOL powerhouse
iOS 8 Healthkit gets a bug SO Apple KILLS it. That's real healthcare!
Not fit for purpose on day of launch, says Cupertino
prev story

Whitepapers

Secure remote control for conventional and virtual desktops
Balancing user privacy and privileged access, in accordance with compliance frameworks and legislation. Evaluating any potential remote control choice.
Intelligent flash storage arrays
Tegile Intelligent Storage Arrays with IntelliFlash helps IT boost storage utilization and effciency while delivering unmatched storage savings and performance.
WIN a very cool portable ZX Spectrum
Win a one-off portable Spectrum built by legendary hardware hacker Ben Heck
High Performance for All
While HPC is not new, it has traditionally been seen as a specialist area – is it now geared up to meet more mainstream requirements?
Beginner's guide to SSL certificates
De-mystify the technology involved and give you the information you need to make the best decision when considering your online security options.