anso/http

Http framework for training project.

dev-master 2020-11-11 12:55 UTC

This package is auto-updated.

Last update: 2025-06-11 23:08:16 UTC


README

Requirements

PHP >= 7.4

Installation

anso/http can be installed via Composer.

composer require anso/http:dev-master

Usage

A few configuration files must be created and placed in a single folder before instantiating Application object and calling start() method:

Afterwards application can be started like this (/public/index.php):

<?php

define('BASE_PATH', __DIR__ . '/..');

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

use Anso\Framework\Base\Configuration;
use Anso\Framework\Base\Container;
use Anso\Framework\Base\Contract\Application;
use Anso\Framework\Http\HttpApp;

$configuration = new Configuration('/config/http');
$container = new Container($configuration);
$app = new HttpApp($container, $configuration);

$container->addResolved(Application::class, $app);

$app->start();
  • BASE_PATH constant is needed to include config files and extract values from them later.
  • To enable autoloading composer's autoload.php must be required.
  • Then Configuration, Container and HttpApp objects must be created. Be sure that you have Application, Container and Configuration registered as singletons either in a provider or right after creating $app object.
  • $app object should be marked as resolved, so that if it is required later, a duplicate app object with wrong config wouldn't be created.
  • Finally the app can start working.