for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace APP\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class Console
{
public function __construct($container)
$this->container = $container;
container
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
public function index(Request $request, Response $response)
$driver = $this->container['config']->get('database.driver');
$host = $this->container['config']->get('database.drivers.mysql.host');
$database = $this->container['config']->get('database.drivers.mysql.database');
$username = $this->container['config']->get('database.drivers.mysql.username');
$password = $this->container['config']->get('database.drivers.mysql.password');
if (!testDatabaseConnectivity($driver, $host, $database, $username, $password)) {
return $response->withHeader('Location', resolveRoute('setup'));
ob_start();
include VIEWS.'index.php';
$view = ob_get_contents();
ob_end_clean();
$response->write($view);
return $response;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: