PHP code example of mvc5 / facade

1. Go to this page and download the library: Download mvc5/facade library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mvc5 / facade example snippets


use Arc5\App;
use Arc5\Request;
use Arc5\Response;
use Arc5\Route;
use Arc5\Service;
use Arc5\View;
use Mvc5\Http\Request as HttpRequest;
use Mvc5\Http\Response as HttpResponse;
use Mvc5\View\ViewModel;
use Mvc5\View\ViewLayout;

use const Mvc5\{ BODY, CONTROLLER, REQUEST, RESPONSE, USER };

Service::context(equest[CONTROLLER];

        $request = $request->with(USER, Service::plugin(USER));

        $controller && $result = Service::call(
            $controller, [REQUEST => $request, RESPONSE => $response]
        );
    }

    if ($result instanceof ViewModel) {
        !$result instanceof ViewLayout && ($layout = View::layout())
            && $result = $layout->withModel($result);

        $result = View::render($result);
    }

    ($result instanceof HttpResponse && $response = $result)
        || $response = $response->with(BODY, $result);

    $response = Response::status($request, $response);
    $response = Response::version($request, $response);
    Response::send($response);

}  catch(\Throwable $exception) {

    App::exception($exception);

}

spl_autoload_register(new Mvc5\Service\Alias(

return [
    'Config'   => Arc5\Config::class,
    'Log'      => Arc5\Log::class,
    'Message'  => Arc5\Message::class,
    'Request'  => Arc5\Request::class,
    'Response' => Arc5\Response::class,
    'Route'    => Arc5\Route::class,
    'Service'  => Arc5\Service::class,
    'Session'  => Arc5\Session::class,
    'View'     => Arc5\View::class,
];

use Response;
use View;

return Response::response(View::render('about/more'));

'service\context', //web event
'web\context', //middleware

'service\context' => new Invoke(Mvc5\Service\Context::class, ['service' => new Link]),
'web\context'     => [Mvc5\Web\Context::class, new Link],

'view5\template' => [ViewTemplate::class, ['import' => ['arc5']]],