Gene Framework Document, gene framework

Source: Internet
Author: User
Tags php error php error log

Gene Framework Document, gene framework
Welcome to the Gene framework

Latest Version: V1.2.2 Open Source Address: https://github.com/sasou/php-gene Author: sasou documentation address: http://php-gene.com/doc
Overview
  • Introduction

    Gene is a flexible, powerful, simple, and efficient c extension framework. Through careful design and efficient technology implementation, combined with database, cache and other class libraries, bring a new development experience.

  • Features
  • Directory structure

    For gene applications, you can follow a directory structure similar to the following. After you are familiar with it, you can customize the directory structure.
    App
    ├ ── Cache
    │ └ ── Views
    ├ ── Ext
    │ ├ ── Com
    │ ─ ── Cache
    │ Sampled-Db
    │ ├-Queue
    ├ ── Config
    ├ ── Controllers
    │ └ ── Admin
    ─ ── Models
    │ ├ ── Admin
    Parameter-Views
    ├ ── Admin
    └ ── Web

Getting started
    • Portal File

      The entry file is the entrance of all requests. Generally, all requests are redirected to this entry file by using the rewrite rules.

      define('APP_ROOT', __dir__ . '/app/');$app = new \Gene\Application();$app  ->load("router.ini.php")  ->load("config.ini.php")  ->run();
    • Route configuration file

      You can configure the http Request Method (get, post, put, patch, delete, trace, connect, options, and head) and configure the route processing function: callback Function and class method (in the format of className @ methodName ).

      $router = new \Gene\Router();$router->clear()->get("/", "\Controllers\Index@run")->error(404,function(){echo " 404 ";})->hook("before", function(){echo " before ";})->hook("after", function($params){echo " after ";});
    • Variable configuration file

      The configuration cache supports data types such as bool, int, long, string, array, and constant.

      $config = new \Gene\Config();   $config->clear();    $config->set("_db",array(        'adapter' => 'Pdo\Mysql',        'host' => '127.0.0.1',        'port' => 3306,        'user' => 'root',        'password' => '123456',        'database' => 'demo',        'charset' => 'utf8',        'persistent' => false,    ));    $config->set("_cache",array('adapter' => 'Memcaches', 'servers' => array('default' => array('host' => '127.0.0.1','port' => 8888,'persistent' => true))));
    • Controller File

      For the \ Controllers \ Index @ run of the route configuration, the Controller directory is the Index. php file under the Controllers directory under the app directory, and the Action name is run.

      namespace Controllers;class Index extends \Gene\Controller{    /**     * run     * @param type $params     */    public function run()    {        echo 'run';    }}
    • Run

      Enter the Project address in the browser, for example, http: // localhost/
      See the before run after output !!!

      NOTE: If before run after is not displayed, check the PHP error log to find out where the problem is.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.