1

Нужно розместить веб приложения в подкаталоге сайта. Для роутинга использую библиотеку Klein.php.

Файл index.php в под папке сайта:

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

use Controllers\AccountController;

$klein = new \Klein\Klein();


$klein->respond('GET', '/list-accounts', function ($request, $response, $service, $app) {
    $account = new AccountController();
    $res = $account->index();
    $service->data = $res['data'];
    $service->escape = function ($str) {
        return htmlentities($str); // Assign view helpers
    };
    $service->render($res['view']);
});

$klein->respond('GET', '/addAccount', function ($request, $response, $service, $app) {
    $account = new AccountController();
    $res = $account->create();
    $service->escape = function ($str) {
        return htmlentities($str); // Assign view helpers
    };
    $service->render($res['view']);
});

$klein->respond('POST', '/addAccount/store', function ($request, $response, $service, $app) {
    $account = new AccountController();
    $params = $request->params();
    $nameFileAccount = $account->store($params);
    return $nameFileAccount;
});

$klein->dispatch();

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Посмотрите другие вопросы с метками или задайте свой вопрос.