Git Product home page Git Product logo

phalcon-autoconf's Introduction

Phalcon autoconf

Phalcon PHP is a web framework delivered as a C extension providing high performance and lower resource consumption.

This is a library and related config file for the Phalcon PHP framework 0.7.0. It's will is to allow a beter control over application bootstrap.

This project is stil not stable, it currently handles :

  • PHP ini_set() definitions
  • Phalcon\Logger
  • Phalcon\Session
  • Phalcon\Db
  • Phalcon\Mvc\Model
  • Phalcon\Mvc\View
  • Phalcon\Mvc\Url
  • Phalcon\Flash

Get started

To use Autoconf you should place the config file in your config folder (ie: app/config/) and use the class in your public/index.php :

This class expect the current directory to be set to application root.

define('DS', DIRECTORY_SEPARATOR);

chdir(__DIR__.DS.'..'.DS);

Then we initialize the application as usually.

try {
    
    //Read the configuration
    $config = new Phalcon\Config\Adapter\Ini(
        'app'.DS.'config'.DS.'config.ini'
    );
    
    $loader = new \Phalcon\Loader();
    
    /**
     * We're a registering a set of directories taken from the configuration 
     * file
     */
    $loader->registerDirs(
        array(
            $config->application->controllersDir,
            $config->application->pluginsDir,
            $config->application->libraryDir,
            $config->application->modelsDir,
        )
    )->register();

Autoconf will need the directories to be defined and will return the dependency injector.

    $autoconf = new Autoconf($config);
    $di = $autoconf->getDi();

Here you can handle plugins, events, etc

    $application = new \Phalcon\Mvc\Application();
    $application->setDI($di);
    echo $application->handle()->getContent();
} catch (Phalcon\Exception $e) {
    echo $e->getMessage();
} catch (PDOException $e) {
    echo $e->getMessage();
}

Don't forget to cusomize app/config/config.ini to your needs.

phalcon-autoconf's People

Watchers

Sergey avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.