PHP code example of psykosoldi3r / slim-doctrine

1. Go to this page and download the library: Download psykosoldi3r/slim-doctrine 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/ */

    

psykosoldi3r / slim-doctrine example snippets


$doctrine = new \Slim\Middleware\Doctrine( \Slim\Container $container, array $configuration );



ainer = new \Slim\Container;
$app = new \App\App( $container );

$doctrine = new \Slim\Middleware\Doctrine(
    $app->getContainer(),
    array(
        "dev_mode" => true,
        "entities" => [
            "paths" => ["src/App/Entity"]
        ],
        "connection" => [
            "driver"    => "pdo_mysql",
            "host"      => "127.0.0.1",
            "dbname"    => "slim_doctrine_demo",
            "user"      => "root",
            "password"  => "root"
        ]
    ));

$app->run();



namespace App\Controllers;

use Interop\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Slim\Middleware\DoctrineResource;

class QuestionController extends DoctrineResource
{
    public function __construct( ContainerInterface $ci ){
        parent::__construct( $ci );
    }
    
    public function exampleAction( ServerRequestInterface $request, ResponseInterface $response, $args ){
        $em = $this->getEntityManager();
    }
}