2017 © Pedro Peláez
 

library framework

Arvici Framework

image

arvici/framework

Arvici Framework

  • Tuesday, March 27, 2018
  • by tomvlk
  • Repository
  • 1 Watchers
  • 3 Stars
  • 115 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 23 Versions
  • 1 % Grown

The README.md

Arvici Framework - Framework Core Package

Build Status License Coverage Status Codacy Badge Codacy Badge, (*1)

Latest Stable Version Latest Unstable Version Dependency Status, (*2)

Arvici Framework, (*3)

Introduction

This package contains the core functionality of the Arvici Framework. Currently being in development!, (*4)

Getting started

Using this package is for experts only, please follow the link bellow to get instructions on how to get started with the framework. Getting started, use composer create-project, (*5)

Components

Router

You can define your routes in the Router.php configuration. Define your routes with the Router::define method., (*6)

Example:, (*7)

Router::define(function(Router $router) {
    $router->get('/',           '\App\Controller\Welcome::index');
    $router->get('/session',    '\App\Controller\Welcome::session');
    $router->get('/json',       '\App\Controller\Welcome::json');
    $router->get('/exception',  '\App\Controller\Welcome::exception');
});

Database

Configuration of your database is located in the Database.php., (*8)

Example:, (*9)

Configuration::define('database', function() {
    return [
        /**
         * The default fetch type to use.
         */
        'fetchType' => \Arvici\Heart\Database\Database::FETCH_ASSOC,

        /**
         * Database Connection names and configuration values.
         *
         * 'default' is used when no connection name is provided, or using SweetORM.
         */
        'connections' => [
            'default' => [
                'driver'        => 'MySQL',
                'host'          => 'localhost',
                'username'      => 'root',
                'password'      => '',
                'port'          => 3306,
                'database'      => 'arvici_test'
            ],
        ]
    ];
});

Models/ORM

When using the ORM, check the separate documentation: https://github.com/tomvlk/sweet-orm#defining-entities, (*10)

Caching

To use the Caching system, you have to define the Caching configuration or use the FileSystem by default., (*11)

Configuration file Cache.php:, (*12)

Configure::define('cache', function () {
    return [

        /**
         * Enable cache.
         */
        'enabled' => true,

        /**
         * Set to true to enable cache even in non-production mode.
         */
        'forceEnabled' => true,

        /**
         * Cache Pool Configuration.
         */
        'pools' => [
            'default' => [
                'driver' => '\Stash\Driver\FileSystem',
                'options' => [
                    'path' => BASEPATH . 'cache' . DS,
                ]
            ],
        ],

    ];
});

Using the cache pools

To retrieve a pool (where you can save and get items) you have to use the Manager:, (*13)

$manager = \Arvici\Component\Cache::getInstance();

In the next step you need to get the Pool. The pool is configured in your configuration file., (*14)

$pool = $manager->getPool(); // pool name = 'default'
// or with a pool name:
$pool = $manager->getPool('redis-cache'); // pool name = 'redis-cache'

To retrieve, save or use an item you first have to get the context. With the instance of Item you can read and manipulate the content., (*15)

Examples of usage:, (*16)

$item = $pool->get('test/cachingkey');
$item->set($data);

$expiration = new DateTime('2020-01-21');
$item->expiresAfter($expiration);

$item->save();

$data = $item->get();

$item->isMiss(); // bool

More information

The caching library that is used is Stash. For more information on using the pools see: http://www.stashphp.com/Basics.html, (*17)

License

MIT License, see LICENSE file., (*18)

The Versions