PHP code example of dida / framework

1. Go to this page and download the library: Download dida/framework library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dida / framework example snippets


return [
    'driver'   => "\\Dida\Db\\Driver\\Mysql",                    // 必填
    'dsn'      => 'mysql:host=localhost;port=3306;dbname=foo',   // 必填
    'username' => 'tom',
    'password' => 'jerry',
    'options'  => [
        PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        PDO::ATTR_PERSISTENT         => true
    ],
];

/*
 * ------------------------------------------------------------
 * 注册服务
 * ------------------------------------------------------------
 */

// Http
ServiceBus::set('Request', \Dida\Http\Request::class);
ServiceBus::set('Response', \Dida\Http\Response::class);
ServiceBus::set('Session', \Dida\Http\Session::class);
ServiceBus::set('Cookie', \Dida\Http\Cookie::class);

// Db
ServiceBus::set("Db", function () {
    $conf =