fm_ph/quark

v1.7.3 2017-10-06 08:59 UTC

README

build status packagist version php-version composer.lock

Server part of quark framework handling mainly the routing and templating.

Features

  • Routing : Methods, regex parameters, redirect, locale.
  • Templating : Twig (layouts, cache, customs extensions, filters, globals...).
  • Locale : IP address detection (Geocoder with providers chain), fallback to prefered browser locale.
  • User agent : Browser, engine, operating system, device, bot and old browser detection.
  • Manifest : Assets hash, environment.
  • Configuration : Supports PHP, INI, XML, JSON, and YAML file formats.
  • Others : Error handler, function helpers.

Installation

Get Composer and run :

composer require fm_ph/quark

Note : You need at least PHP 7.x (CLI) installed on your machine to use this package (verify it with php -v).

For OS X users, you can easily update it on https://php-osx.liip.ch/.

Usage

Basic

Get an Application singleton instance and render matched route template.

<?php

define('BASE_PATH', __DIR__);

// Require Composer autoloader
require BASE_PATH . '/vendor/autoload.php';

// Get Application instance and init
$app = Quark\Application::getInstance();
$app->init();

// Render
echo $app->render();

Custom configuration

Init Application with custom configuration.

<?php

// ...

// Custom configuration
$config = [
  'locale' => [
    'code' => 'fr',
    'redirectIfOne' => true
  ]
]

// Get Application instance
$app = Quark\Application::getInstance();

// Init with custom configuration array
$app->init($config);

Configuration

All configuration properties that can be passed to init() method on an Application instance.

Old browser

Locale

Paths

Twig

API

See https://fm-ph.github.io/quark-server/

Testing

Install PHPUnit globally :

composer global require phpunit/phpunit

And run the tests with :

phpunit

License

MIT License © Patrick Heng Fabien Motte