Book Image

Learning Phalcon PHP

Book Image

Learning Phalcon PHP

Overview of this book

Table of Contents (17 chapters)
Learning Phalcon PHP
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preparing the initial DI interface and the router


In the Bootstrap, we don't have two files: services.php and routing.php. The services.php file will hold the information about global services that our application will use, and the routing.php file will hold information about our routes. Let's start by creating the services.php file in our config folder with the following content:

<?php
use \Phalcon\Logger\Adapter\File as Logger;

$di['session'] = function () use ($config) {

    $session = new \Phalcon\Session\Adapter\Redis(array(
        'uniqueId' => $config->session->unique_id,
        'path' => $config->session->path,
        'name' => $config->session->name
    ));

    $session->start();

    return $session;
};

$di['security'] = function () {
    $security = new \Phalcon\Security();
    $security->setWorkFactor(10);

    return $security;
};

$di['redis'] = function () use ($config) {
    $redis = new \Redis();
    $redis->connect(
        ...