1. Go to this page and download the library: Download bogdanpet/orthite-di 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/ */
bogdanpet / orthite-di example snippets
class User {
public function __construct(Request $request, Database $db) {
.
.
.
}
}
class Database {
public function __construct(\PDO $pdo) {
.
.
.
}
}
class Request {
.
.
.
}
$request = new Request();
$pdo = new PDO($dsn, $username, $passwd);
$db = new Database($pdo);
$user = new User($request, $db);
// No previous instantiation of container is , 'username', 'passwd');
class User {
public function __construct(Request $request, Database $db) {
.
.
.
}
public function show(Response $response, $id) {
.
.
.
return $response(...$something);
}
}