rnr1721 / le7-core
Core files for le7 PHP MVC framework with API,CLI,WEB controllers
1.1.7
2023-12-03 17:44 UTC
Requires
- php: >=8.1
- ext-gettext: *
- ext-json: *
- ext-posix: *
- fig/http-message-util: ^1.1
- maximebf/debugbar: 1.*
- psr/event-dispatcher: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^2.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
- psr/log: ^3.0
- psr/simple-cache: ^3.0
- rnr1721/le7-config: ^1.0
- rnr1721/le7-cookie-wrapper: ^1.0
- rnr1721/le7-event-manager: ^1.0
- rnr1721/le7-messages: ^1.0
- rnr1721/le7-middleware: ^1.0
- rnr1721/le7-view: ^1.0.0
- rnr1721/le7-view-php: ^1.0
Requires (Dev)
- phpunit/phpunit: ^10.0
- rnr1721/le7-testing: ^1.0
- vimeo/psalm: ^5.7
README
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); }