web-complete / mvc
Micro MVC
1.1.4
2017-12-11 17:11 UTC
Requires
- php: >=7.0.0
- filp/whoops: ~2.1
- nikic/fast-route: ^1
- php-di/php-di: ^5
- symfony/filesystem: ^3.3
- symfony/http-foundation: ^3
- web-complete/core: *
Requires (Dev)
- mvkasatkin/mocker: ^1
- phpunit/phpunit: ^6
README
Example index.php
<?php require __DIR__ . '/../../vendor/autoload.php'; defined('ENV') or define('ENV', in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'], false) ? 'dev' : 'prod'); $config = require __DIR__ . '/../../admin/config/config.php'; $application = new \WebComplete\mvc\Application($config); $front = $application->getContainer()->get(\WebComplete\mvc\front\FrontController::class); $front->dispatch()->send();
Example config.php
<?php return [ 'aliases' => [ '@app' => \dirname(__DIR__ . '/../app'), '@web' => \dirname(__DIR__ . '/../web'), ], 'routes' => [ ['GET', '/post/list', [\app\controllers\PostController::class, 'actionList']], ['POST', '/post/update', [\app\controllers\PostController::class, 'actionUpdate']], ], 'cubesLocations' => [ '@app/cubes', ], 'definitions' => [ 'errorController' => \DI\object(\app\controllers\ErrorController::class), ] ];
Example controller.php
<?php namespace app\controllers; class SomeController extends AbstractController { protected $layout = '@app/views/layouts/main.php'; public function index() { return $this->responseHtml('@app/views/some/index.php', ['name' => 'World']); } }