taviroquai/duality-demo

该包的最新版本(v1.0.0)没有提供许可证信息。

Duality PHP 框架项目

安装: 10

依赖项: 0

建议者: 0

安全: 0

星星: 1

关注者: 2

分支: 0

开放问题: 0

语言:JavaScript

v1.0.0 2014-12-07 21:11 UTC

This package is auto-updated.

Last update: 2024-09-08 06:52:30 UTC


README

安装

  1. 下载 zip 文件并将其 解压 到 Apache 网络目录中
  2. 使用 composer 安装依赖项:php composer.phar install
  3. 在 Apache 服务器上启用 mod rewrite
  4. 编辑 config/app.php 并更改您的本地设置
  5. 在浏览器中打开 https:///duality-demo/

最小 API 使用示例

    // Include local configuration
    $config = array(
    'server' => array(
            'url' => '/duality-demo',
            'hostname' => 'localhost'
        )
    );
        
    // Load dependencies
    require_once './vendor/autoload.php';
      
    // Create a new application container
    $app = new \Duality\App(dirname(__FILE__), $config);

    // Get server and request
    $server = $app->call('server');
    $request = $server->getRequestFromGlobals($_SERVER, $_REQUEST);

    // Validate HTTP request
    if (!$request) die('HTTP request not found!');

    // Set request
    $server->setRequest($request);
     
    // Define default route
    $app->call('server')->setHome(function(&$req, &$res) {
       
        // Tell response what is the output
        $res->setContent('Hello World!');
    });
        
    // Finaly, tell server to start listening
    $app->call('server')->listen();