Giter Club home page Giter Club logo

le7-core's Introduction

le7-core

This package is core of le7 PHP MVC framework. You can use it in your own project.

Requirements

  • PHP 8.1 or higher.
  • Composer 2.0 or higher.

Basic usage

This is only core. To install this framework, llease visit https://github.com/rnr1721/le7-framework for more information. You must use le7 project skeleton to use it.

index.php in public folder

<?php

define('PUBLIC_PATH', realpath(dirname(__FILE__)));

require_once '../bootstrap.php';

bootstrap.php

declare(strict_types=1);

use Nyholm\Psr7Server\ServerRequestCreator;
use Core\Topology;
use Core\InitHttp;
use Core\InitCli;
use App\Classes\Factories\ContainerFactoryPhpDi;

if (!defined('PUBLIC_PATH')) {
    // Prevent to launch not from public folder
    echo 'Please run program from webroot folder' . PHP_EOL;
    exit;
}

// Set microtime for measuring page generation time
$start = microtime(true);

define('BASE_PATH', realpath(dirname(__FILE__)));

define('DS', DIRECTORY_SEPARATOR);

$diCompiledPath = BASE_PATH . DS . 'var' . DS . 'containers';
$diConfig = BASE_PATH . DS . 'config' . DS . 'di';

$loader = require('vendor' . DS . 'autoload.php');

$topology = new Topology(PUBLIC_PATH, BASE_PATH);

$containerFactory = new ContainerFactoryPhpDi($diConfig, $diCompiledPath);

if (php_sapi_name() === 'cli') {
    $init = new InitCli($containerFactory, $topology);
    $init->run();
} else {
    $init = new InitHttp($containerFactory, $topology);
    $factory = new Nyholm\Psr7\Factory\Psr17Factory();
    $creator = new ServerRequestCreator(
            $factory, // ServerRequestFactory
            $factory, // UriFactory
            $factory, // UploadedFileFactory
            $factory  // StreamFactory
    );
    $request = $creator->fromGlobals();
    $response = $init->run($request);
}

le7-core's People

Stargazers

Coding for good. avatar

Watchers

Eugeny G avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.