It's time to remove all "include" statements. Just use spl_autoload_register
<?php
spl_autoload_register(function ($class_name) {
include $class_name . '.php';
});
// include 'config/database.php';
$db = new \config\Database();
// include 'service/PostService.php';
$s = new \service\PostService($db);
$postID = 2;
print_r($s->readPost($postID));
$c = $s->readPost($postID);
$class_methods = get_class_methods($c);
foreach ($class_methods as $method_name) {
echo "$method_name";
}
echo $c->getTitle() <br&gr;;
echo $c->getAuthor()<br&gr;;
echo $c->getContent() <br&gr;;
?>
This is the result: