1. Go to this page and download the library: Download nyholm/super-slim 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/ */
nyholm / super-slim example snippets
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @ORM\Table(name="products")
*/
class Product
{
/**
* @ORM\Id()
* @ORM\Column(type="integer")
* @ORM\GeneratedValue()
*/
protected $id;
/**
* @ORM\Column(type="string")
*/
protected $name;
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
}
// cli-config.php
use App\Kernel;
_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel->boot();
return $kernel->getContainer()->get('doctrine.console_helper');
namespace App\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment;
class MyTwigController
{
private $twig;
public function __construct(Environment $twig)
{
$this->twig = $twig;
}
public function index()
{
return new Response($this->twig->render('index.html.twig', ['name' => 'Foobar']));
}
}
namespace App\Middleware;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
class Cache implements MiddlewareInterface
{
private $cache;
public function __construct(CacheInterface $cache)
{
$this->cache = $cache;
}
public function __invoke(Request $request, RequestHandlerInterface $handler): Response
{
$cacheKey = sha1($request->getUri());
return $this->cache->get($cacheKey, function (ItemInterface $item) use ($handler, $request) {
$item->expiresAfter(3600);
return $handler->handle($request);
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.