1. Go to this page and download the library: Download simplemvc/framework 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/ */
simplemvc / framework example snippets
chdir(dirname(__DIR__));
;
use SimpleMVC\App;
use SimpleMVC\Emitter\SapiEmitter;
$builder = new ContainerBuilder();
$builder->addDefinitions('config/container.php');
$container = $builder->build();
$app = new App($container);
$app->bootstrap(); // optional
$response = $app->dispatch(); // PSR-7 response
SapiEmitter::emit($response);
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use SimpleMVC\Controller\AttributeInterface;
use SimpleMVC\Controller\AttributeTrait;
use SimpleMVC\Controller\ControllerInterface;
class A implements ControllerInterface, AttributeInterface
{
use AttributeTrait;
public function execute(
ServerRequestInterface $request,
ResponseInterface $response
): ResponseInterface
{
$this->addRequestAttribute('foo', 'bar');
return $response;
}
}
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use SimpleMVC\Controller\ControllerInterface;
class B implements ControllerInterface
{
public function execute(
ServerRequestInterface $request,
ResponseInterface $response
): ResponseInterface
{
$attribute = $request->getAttribute('foo');
pritnf("Attribute is: %s", $attribute);
return $response;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.