Skip to content
Oni edited this page Sep 13, 2010 · 5 revisions

Admittedly, deployment is a bit of a pain. Tessera by itself offers you no sugar or link helpers as of this writing, so it’s basically up to you. The upside is that how you deploy is completely up to you! For our purposes though, this Tessera example application will be on your assumed domain tesseratic.com running on Apache and mod_rewrite.

Putting The Pieces Together

When uploading things, just put them in your document root. It’s totally possible to run Tessera from a subdirectory, but the tutorial assumes everything is in the root directory. That said, upload yourapp.php and tessera.php.

Setting up mod_rewrite

This example .htaccess will allow you to serve static files like images and stylesheets, and prevent access to your /views directory as well as provide clean URLs.

<Directory /views/>
  Order deny,allow
  Deny from all
  Allow from none
</Directory>

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^$ yourapp.php?/ [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule (.*) yourapp.php?/$1 [L]
</IfModule>

Using a Link Helper

Using a link helper tailored to your application is probably the smartest way to go. A simple way to do it would be to define a method inside your application’s superclass:

function link($path = '/', $text = null) {
    if ($path{0} != '/') {
        $path = "/{$path}";
    }
    $url = defined(CLEAN_URLS) ? $path : sprintf('%s?%s', basename($_SERVER['PHP_SELF']), $path);
    return sprintf('<a href="%s">%s</a>', $url, isset($text) ? $text : $url);
}

Now the code will format URLs according to whether or not you’re using clean URLs, according to the CLEAN_URLS constant that is assumed to be defined somewhere in your code. To use it in views and layouts, call it like <?php echo $this->link("some/url/", "This is a Link"); ?>. It automatically prepends a forward slash if necessary, and if no arguments are given it points to the root directory. It also wouldn’t be hard to generalize, or add methods to include static resources like stylesheets or images.

Clone this wiki locally