Table of Contents

Rack

Rack β€” A framework, typically with rails, bars, hooks, or pegs, for holding or storing things.

Rack is a small and simple boilerplate/framework for PHP based web applications that are integrated with the login API of the Cover website. It aims to ease the creation of websites or microservices that only need a small number of forms, tables and views and to provide a familiar project structure among most of Cover's PHP projects. Additionally, anybody with basic OOP skills and a basic understanding of the web should be able to easily comprehend the framework and setup a website.

Rack implements the following features:

Future improvements:

Rather than providing a fully-featured API, Rack aims to provide just enough functionality to cover the basic needs. Projects with more complicated requirements should extend, subclass and/or override Rack code where needed to add functionality.

Getting Started

Installation

Clone (or fork or download) the Bitbucket repository into the root folder of your project and you're ready to go!

Project structure

Projects using Rack adhere to the following structure:

πŸ“ Project
β”œ πŸ“ include
β”‚ β”œ πŸ“ models
β”‚ β”‚ β”œ πŸ“ migrations
β”‚ β”‚ β”œ Model.class.php
β”‚ β”‚ β”” … (model definitions)
β”‚ β”œ config.php
β”‚ β”œ include.php
β”‚ β”” … (other Rack logic php files)
β”œ πŸ“ static
β”‚ β”œ πŸ“ css
β”‚ β”œ πŸ“ js
β”‚ β”œ πŸ“ img
β”‚ β”” … (other static content)
β”œ πŸ“ templates
β”‚ β”œ error.phtml
β”‚ β”œ index.phtml
β”‚ β”œ layout.phtml
β”‚ β”” … (templates for other views)
β”œ index.php
β”” … (other views)

The include folder is meant Rack's internal logic and possible application-specific extensions to it. It should not contain any views, templates or static files.

Configuration

A config file include/config.php is needed for Rack to work properly. A default configuration is provided in include/config.php.default which can be copied to initialize the config.php file. Remember that this config file is likely to contain passwords, so it should be added to the .gitignore file to prevent it from showing up in Git repositories. Do not forget to change it's file permissions to hide it from other users on the system. This can be done with the following command: chmod 700 include/config.php. All available configuration options are listed here.

Creating views

Now, you're ready to create views. A view is a php file in the project's root folder. Every view should include (or require) the include/init.php file, to load the Rack functionality. An example of a view that renders the template templates/index.php is provided below:

index.php
<?php
require_once 'include/init.php';
 
// Create and run home view
$view = new TemplateView('index');
$view->run();

Glossary

API Reference

The following pages contain short documentation of the available classes and functions. They are meant to provide an overview of the features and dataflows. Anybody in need of implementation specific detail is advised to inspect the source code.

Versions