fm_ph / quark
Quark server
v1.7.3
2017-10-06 08:59 UTC
Requires
- php: ^7.0
- fig/http-message-util: ^1.1
- filp/whoops: ^2.1
- geocoder-php/chain-provider: ^4.0
- geocoder-php/free-geoip-provider: ^4.0
- geocoder-php/geo-plugin-provider: ^4.0
- geocoder-php/host-ip-provider: ^4.0
- gpolguere/path-to-regexp-php: dev-master
- hassankhan/config: ^0.10.0
- nochso/html-compress-twig: ^2.0
- php-http/guzzle6-adapter: ^1.1
- php-http/message: ^1.5
- symfony/yaml: ^3.2
- twig/twig: ^2.4
- whichbrowser/parser: ^2.0
- willdurand/geocoder: 4.1.0
README
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
Property | Type | Description | Default |
---|---|---|---|
old_browser | array |
List of old browsers. | See Config.php |
Locale
Property | Type | Description | Default |
---|---|---|---|
locale.code | string |
Locale code fallback. | en |
locale.country | string |
Locale country fallback. | |
locale.redirectIfOne | boolean |
Router redirect to include locale in URL if only one is found. | false |
Paths
Property | Type | Description | Default |
---|---|---|---|
paths.locales | string |
Path to locale files. locale variable is replaced with the current locale. |
locales/{{locale}}.yml |
paths.routes | string |
Route file path. | routes.yml |
paths.manifest | string |
Manifest file path. | manifest.json |
Twig
Property | Type | Description | Default |
---|---|---|---|
twig.layouts | array |
Twig layouts name. | See below |
twig.layouts.default | string |
Twig default layout name to be rendered. | default |
twig.layouts.old_browser | string |
Twig old browser layout name. | old |
twig.extension | string |
Twig template file extension. | .twig |
twig.cache | string |
Twig cache path. | cache |
twig.extraData | any |
Twig extra data merged with template data. | [] |
twig.paths.views | string |
Views folder path. | views |
twig.paths.layouts | string |
Layouts folder path. | views/layouts |
twig.paths.pages | string |
Pages folder path. | views/pages |
twig.paths.components | string |
Components folder path. | views/components |
twig.extensions | array |
Twig extensions (manifest and html compress extensions are activated by default). | [] |
twig.filters | array |
Twig filters. | [] |
twig.globals | array |
Twig globals. | [] |
twig.functions | array |
Twig functions | [] |
twig.tests | array |
Twig tests. | [] |
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