Skip to content

Setting up Standalone Pages

kbrookes edited this page Aug 5, 2021 · 9 revisions

Local or Remote?

After following the composer installation process you will have a folder called 'vendor' in your installation directory.

If you're working locally, your installation directory will be your web root.

Otherwise, upload the vendor folder to your remote web root.

Required files and folders

To be able to test your installation you will need to ensure Pages is called properly, and is able to access files stored in the standard folder structure. Additionally, you will need an .htaccess file for routing and some config files.

index.php

Your index.php file will intercept all requests, and use the Pages router to direct them to the correct page. To do this, we need to instansiate the bootstrapper in the vendor directory.

Here is the contents of the index.php in the web root:

define('KOOWA_ROOT', __DIR__);
define('KOOWA_DEBUG', 1);

require KOOWA_ROOT.'/vendor/joomlatools/pages/resources/pages/bootstrapper.php';

Note - debugging is turned on in this example.

Configuration options

There are three configuration files required for standalone:

config.php /config/koowa.php /config/pages.php

In the web root, the config.php file sets up

  • aliases for important locations; theme files, images, etc
  • where your extensions folders are (if required)
  • Logging and cache locations
  • custom configuration options

The default config.php should look like this:

<?php

return [

    'cache_path'      => KOOWA_ROOT.'/cache',
    'log_path'        => KOOWA_ROOT.'/logs',

    'aliases' =>
    [
        'theme://'  => '/theme/',
        'images://' => '/images/',
    ],

    'extension_path' =>
    [
        PAGES_SITE_ROOT . '/extensions',
        KOOWA_ROOT.'/extensions',
    ],

    'extension_config'     =>
    [
       //custom config
    ]
];

The /config/pages.php file is critical for setting up the standalone environment, as it defines where the root of the Pages installation is, vs where it would be in a standard Joomla install:

<?php

return array(

   //Use / directory instead of default /joomlatools-pages
    'sites' => [
        '[*]' => KOOWA_ROOT,
    ],

    //Alias debugger assets to use joomlatools CDN
    'aliases' => [
        'media://koowa/framework/css/debugger.css' => 'https://files.joomlatools.com/joomlatools-framework@3.5.0/resources/assets/css/debugger.min.css',
        'media://koowa/framework/js/debugger.js' => 'https://files.joomlatools.com/joomlatools-framework@3.5.0/resources/assets/js/debugger.min.js',
    ],
);

/config/koowa.php then sets up debugging and some core services:

<?php
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL); //For development
//ini_set('error_reporting', E_ERROR | E_PARSE);  //For production

return [

    /* Site */
    'sitename'   => 'Example Site',
    'list_limit' => '20',

    /* Locale */
    'offset'     => 'UTC',
    'language'   => 'en-GB',

    /* Mail */
    'mailer'     => 'mail',
    'mailfrom'   => 'noreply@example.com',
    'fromname'   => 'Example Site',
    'sendmail'   => '/usr/sbin/sendmail',
    'smtpauth'   => '0',
    'smtpuser'   => '',
    'smtppass'   => '',
    'smtphost'   => 'localhost',
    'smtpsecure' => 'none',

    /* Cache */
    'caching'     => 0,
    'lifetime'    => '15',

    /* Debug */
    'debug'     => KOOWA_DEBUG
];

Setup .htaccess

You'll need to setup .htaccess to access pretty URLs in Pages:

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

Test Pages

Now that all the configuration options have been set, it's time to test the standard file/folder structure of Pages to ensure everything is working as expected.

  1. In the web root, create a folder called 'pages'.
  2. In /pages/ add hello.html
  3. add <h1>Hello</h1> to hello.html

Visit the frontend of your site at yoursite.com/hello - and you should now see the output of that file.

If so, everything is working and you're ready to start development.