iluxaorlov/deviant

Deviant PHP 微框架

v1.0.1 2020-06-10 17:59 UTC

This package is auto-updated.

Last update: 2024-09-23 16:47:05 UTC


README

安装框架

建议使用 Composer 进行安装

$ composer require iluxaorlov/deviant

开始使用

创建包含基本内容的 public/index.php 文件

<?php

use Deviant\Component\Response;
use Deviant\Component\Request;

require_once __DIR__ . '/../vendor/autoload.php';

// Инициализация приложения
$app = new Deviant\App();

// Настройка роутинга
$app->get('/', function(Response $response, Request $request, array $args) {
    return $response->withBody('Hello World');
});

$app->get('/hello/{name}', function(Response $response, Request $request, array $args) {
    $name = $args['name'];
    $response->withBody('Hello, ' . $name);
    return $response;
});

// Запуск приложения
$app->run();

使用内置的 PHP 服务器检查我们的应用程序

$ php -S localhost:8000 -t public

通过地址 https://:8000/ 访问,我们看到 "Hello World" 文字