This article is more than 1 year old

Get your PHP on the right Trax

Framework flattery

A database.ini database configuration file gets created in the config directory. Modify the database.ini file for the MySQL database. We shall be using the development mode as follows:

[development]
    phptype = mysql
    database = test
    hostspec = localhost
    username = root
    password = 
  persistent = true

Modify the config/environment.php directory to set the PHP directory, the trax root directory, and the trax environment mode. Define variables PHP_LIB_ROOT, TRAX_ROOT, and TRAX_ENV.

define("PHP_LIB_ROOT",    "C:/PHP/PEAR");
define("TRAX_ROOT",       "C:/Apache/htdocs/catalog");
define("TRAX_ENV",    "development");

The public/.htaccess file specifies configuration directives for the Apache HTTP server. The configuration directives in the .htaccess file apply to the directory in which the .htaccess file is placed and the sub-directories of the directory. Modify the public/.htaccess file. Replace the following line with the subsequent line:

php_value include_path .:C:\Apache\htdocs\catalog/config
php_value include_path .;C:\Apache\htdocs\catalog/config

The include_path directive specifies a list of directories and is used to locate files. Access the Trax application console with the URL http://localhost/catalog/public.

Modify the C:\Apache\conf\httpd.conf file so the directives in the .htaccess file may override earlier access information. Activate the mod_rewrite module by removing the '#' before the following line:

LoadModule rewrite_module modules/mod_rewrite.so

The mod_rewrite module provides a rules-based rewriting engine to rewrite requested URLs. Also set all the AllowOverride directives to All.

AllowOverride All

The AllowOverride directive specifies which directives in the .htaccess may override earlier access information. Modify the DocumentRoot directive and <Directory> setting in httpd.conf to the following:

DocumentRoot "C:/Apache/htdocs/catalog/public"
<Directory "C:/Apache/htdocs/catalog/public">

Reboot time

Restart the Apache server. We shall generate a model class and the scaffolding for the model class, which models a database table, with the scaffold generator. Create a scaffold.bat file in the C:\Apache\htdocs\catalog directory. Copy the following code to the scaffold.bat file:

php ./script/generate.php scaffold  %1 %2

Before creating the scaffolding, build a database table catalogs in the MySQL database with the SQL script catalog.sql. The primary key field should be "id" and of type INT. Create a scaffolding for the "catalogs" table with the following command:

C:\Apache\htdocs\catalog>scaffold catalog catalog

A model class catalog.php gets generated in the models directory.

<?php
class Catalog extends ActiveRecord {      
}
?>

More about

TIP US OFF

Send us news


Other stories you might like