Skip to content

Installation

cepharum GmbH edited this page Apr 30, 2015 · 3 revisions

Prerequisites

Choose Names

  1. Choose a name for your application. In this example we call it foobar.
  2. Choose a name for your initial view. Let's call it home.

Download TXF to your Web Space

  1. Log in to your web server.
  2. Switch to your web space folder: cd /var/www
  3. Clone git repository: git clone https://github.com/cepharum/txf.git

Now you have folder /var/www/txf/txf containing all files of framework.

Create application folder

First, create folder for your application next to the inner txf folder:

mkdir /var/www/txf/foobar

Next create script for rendering initial view.

cat >/var/www/txf/foobar/home.php <<EOT
<?php
namespace de\toxa\txf;
view::main( "Hello World!" );
EOT

This will write the script

<?php
namespace de\toxa\txf;
view::main( "Hello World!" );

to the file /var/www/txf/foobar/home.php.

Set up Web Server Software

Setting up server involves these tasks:

  1. Ensure requests are forwarded to capturing collector script of txf in /var/www/txf/run.php.
  2. Include rule for showing initial view of application unless user is explicitly requesting view.

Apache 2.2+

Using Separate Virtual Host

<VirtualHost *:80>
    ServerName foobar.example.com

    DocumentRoot /var/www/txf/foobar

    SetEnv TXF_DOCUMENT_ROOT /var/www/txf
    SetEnv TXF_APPLICATION foobar

    Alias /txf/run.php /var/www/txf/run.php

    <Directory /var/www/txf/foobar>
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        allow from all

        RewriteEngine On
        RewriteBase /

        # select some default application
        RewriteRule ^$ home [R,L]

        # all requests for unknown resources are processed using global script
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule .* /txf/run.php [L]
    </Directory>
</VirtualHost>>

Contained in Existing Virtual Host

Alias /foobar /var/www/txf/foobar
Alias /txf/run.php /var/www/txf/run.php

# provide pathname of folder containing txf and any installed application 
# unless document root of web server is pointing there already
SetEnv TXF_DOCUMENT_ROOT /var/www/txf

<Directory /var/www/txf/foobar>
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    allow from all

    RewriteEngine On

    RewriteBase /foobar

    # select some default application
    RewriteRule ^$ home [R,L]

    # all requests for unknown resources are processed using global script
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* /txf/run.php [L]
</Directory>

nginx

Using Separate Virtual Host

server {
        listen 80;

        server_name foobar.example.com;

        root /var/www/txf/foobar;

        location = /run.php {
                alias /var/www/txf;

                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;

                include fastcgi_params;

                fastcgi_param TXF_DOCUMENT_ROOT /var/www/txf;
                fastcgi_param TXF_APPLICATION foobar;

                # This might be contained in included fastcgi_params as well:
                fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
                fastcgi_param QUERY_STRING    $query_string;
                # Set if request is over https.
                # fastcgi_param HTTPS         $https if_not_empty;
        }

        location = / {
                rewrite / /home permanent;
        }

        location ~ ^/txf|/config/|/classes/|/skins/ {
                deny all;
        }

        location ~ /assets/ {
                try_files $uri =404;
        }

        location / {
                try_files $uri /run.php?$args;
        }

        # Deny access to .htaccess files, if an Apache's document root
        # concurs with nginx's one.
        location ~ /\.ht {
                deny all;
        }

        # Prevent unprocessed access on PHP scripts.
        location ~ \.php(/.+)?$ {
                deny all;
        }
}

Try it!

Use your favourite browser for opening URL of your installation at http://foobar.example.com or http://example.com/foobar depending on whether having set up application in a separate virtual host or contained in an existing one. Of course you need to choose different domain than example.com in either case.

This will open a nearly blank page showing well-formed XHTML document reading "Hello World!". By inspecting the document you will encounter a properly set of DOM elements ready for rendering multi-column views. The page is simply missing some styling, yet.