PHPonTrax
[ class tree: PHPonTrax ] [ index: PHPonTrax ] [ all elements ]
Prev Next

Build A Simple Trax Application

Let's learn about Trax by using it to build a simple application. We assume you have installed Trax on your system as described above. We'll also assume that we are building our web site in the Apache DocumentRoot directory which is set to /var/www/html, and that the computer we are building on can be accessed from a browser as localhost .

Create The Trax Work Area

The first step is to create a Trax work area for the site. This work area will hold files describing the site. For security reasons, we don't want those files accessible from the Internet, so we avoid putting them under /var/www/html. We use the trax command and give it a location to build the work area. We choose the /var/www/trax directory because it is not accessible from the Internet.

$ trax /var/www/trax
/var/www/trax// created
/var/www/trax/lib/ created
/var/www/trax/vendor/ created
/var/www/trax/script/ created
/var/www/trax/script/generate.php created
/var/www/trax/README created
/var/www/trax/db/ created
/var/www/trax/components/ created
/var/www/trax/public/ created
/var/www/trax/public/stylesheets/ created
/var/www/trax/public/images/ created
/var/www/trax/public/robots.txt created
/var/www/trax/public/dispatch.php created
/var/www/trax/public/.htaccess created
/var/www/trax/public/index.html created
/var/www/trax/public/javascripts/ created
/var/www/trax/public/javascripts/controls.js created
/var/www/trax/public/javascripts/dragdrop.js created
/var/www/trax/public/javascripts/effects.js created
/var/www/trax/public/javascripts/prototype.js created
/var/www/trax/app/ created
/var/www/trax/app/views/ created
/var/www/trax/app/views/layouts/ created
/var/www/trax/app/views/layouts/application.phtml created
/var/www/trax/app/helpers/ created
/var/www/trax/app/helpers/application_helper.php created
/var/www/trax/app/models/ created
/var/www/trax/app/controllers/ created
/var/www/trax/app/controllers/application.php created
/var/www/trax/app/application_mailer.php created
/var/www/trax/test/ created
/var/www/trax/config/ created
/var/www/trax/config/routes.php created
/var/www/trax/config/environment.php created
/var/www/trax/config/environments/ created
/var/www/trax/config/environments/production.php created
/var/www/trax/config/environments/test.php created
/var/www/trax/config/environments/development.php created
/var/www/trax/config/database.ini created
/var/www/trax/log/ created
/var/www/trax/log/test.log created
/var/www/trax/log/production.log created
/var/www/trax/log/server.log created
/var/www/trax/log/development.log created
/var/www/trax/doc/ created
/var/www/trax/doc/README_FOR_APP created
trax creates a number of directories and installs files in some of them. trax tells you what it is doing.

One of the directories trax created is /var/www/trax/public . Let's look inside:

$ ls -Al /var/www/trax/public
total 28
-rw-rw-r--  1 haas haas  217 Mar 26 19:55 dispatch.php
-rw-rw-r--  1 haas haas 1039 Mar 26 19:55 .htaccess
drwxrwxr-x  2 haas haas 4096 Mar 26 19:55 images
-rw-rw-r--  1 haas haas 2829 Mar 26 19:55 index.html
drwxrwxr-x  2 haas haas 4096 Mar 26 19:55 javascripts
-rw-rw-r--  1 haas haas  106 Mar 26 19:55 robots.txt
drwxrwxr-x  2 haas haas 4096 Mar 26 19:55 stylesheets
These files are meant to be visible to the Internet, unlike the other files in the Trax work area. We need to move them to where Apache can serve them:
$ mv /var/www/trax/public/* /var/www/trax/public/.htaccess /var/www/html
Now a browser should be able to visit the index.html file. We verify this by browsing http://localhost where we see Congratulations, you've put PHP on Trax! (if you don't see this, refer to Troubleshooting).

The index.html file has done its work by showing us that Apache accesses our directory. It does not play any part in normal Trax operation, so we delete it:

$ rm /var/www/html/index.html
and again browse to http://localhost. This time we see Controller not found (if you don't see this, refer to Troubleshooting).

This completes the basic installation of Trax.


Prev Up Next
Examples From The Rails Book PHP On Trax Create A Database and User

Documentation generated on Thu, 04 May 2006 19:46:54 -0600 by phpDocumentor 1.3.0RC4