-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
- Choose a name for your application. In this example we call it
foobar. - Choose a name for your initial view. Let's call it
home.
- Log in to your web server.
- Switch to your web space folder:
cd /var/www - Clone git repository:
git clone https://github.com/cepharum/txf.git
Now you have folder /var/www/txf/txf containing all files of framework.
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.
Setting up server involves these tasks:
- Ensure requests are forwarded to capturing collector script of txf in
/var/www/txf/run.php. - Include rule for showing initial view of application unless user is explicitly requesting view.
<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>>
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>
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;
}
}
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.