PHP komunikacja z SQL - Class not found

0

Bardzo prosze o pomoc w debugowaniu PHP scriptu - chodzi o połączenie z bażą danych. Oto init.php

<?php

$dbConfig = Config::getInstance()->get("db");
$db = new PDO(
    "mysql:host=127.0.0.1;dbname=bookstore",
    $dbConfig["user"],
    $dbConfig["password"]
);
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);

$rows = $db->query("SELECT * FROM book ORDER BY title");
foreach ($rows as $row) {
    var_dump($row);
}

$query = <<<SQL
INSERT INTO book (isbn, title, author, price)
VALUES ("9788187981954", "Peter Pan", "J.M. Barrie", 2.34)
SQL;
$result = $db->exec($query);
var_dump($result);
$error = $db->errorInfo()[2];
var_dump($error);

$query2="SELECT * FROM book WHERE author=:author";
$statement = $db->prepare($query);
$statement->bindValue("author", "George Orwell");
$statement->execute();
$rows = $statement->fetchAll();
var_dump($rows);
?>

Config.php

<?php
    namespace Bookstore\Utils;
    use Bookstore\Utils\NotFoundException;

    class Config {
        private $data;
        private static $instance;

        public function __construct() {
            $json = file_get_contents(__DIR__ . "/../../config/app.json");
            $this->data = json_decode($json, true);
            //self::$data = json_decode($json, true);
        }
        public static function getInstance() {
            if (self::$instance==null) {
                self::$instance = new Config();
            }
            return self::$instance;
        }

        public static function get($key) {
            if (!isset($this->data[$key])) {
                throw new NotFoundException("Key $key not in config.");
            }
            return $this->data[$key];
        }
    }
?>

Bardzo chciaabym wiedzieć dlaczego podczas odświeżania localhost/init.php pisze "class Config not found" pomimo że wszystko sie zgadza

0

'''
18
Listening on http://localhost:8000
Document root is /home/nedlo/programming/php7_lopez
Press Ctrl-C to quit.
[Tue Dec 4 23:27:13 2018] PHP Fatal error: Uncaught Error: Class 'Bookstore\Utils\Config' not found in /home/nedlo/programming/php7_lopez/init.php:65
Stack trace:
#0 {main}
thrown in /home/nedlo/programming/php7_lopez/init.php on line 65
[Tue Dec 4 23:27:13 2018] 127.0.0.1:38932 [500]: /init.php - Uncaught Error: Class 'Bookstore\Utils\Config' not found in /home/nedlo/programming/php7_lopez/init.php:65
Stack trace:
#0 {main}
thrown in /home/nedlo/programming/php7_lopez/init.php on line 65
[Tue Dec 4 23:27:13 2018] 127.0.0.1:38934 [404]: /favicon.ico - No such file or directory
[Tue Dec 4 23:27:13 2018] 127.0.0.1:38936 [404]: /favicon.ico - No such file or directory
'''

Bardzo prosze o pomoc

0

w pliku init.php w linii 65 nie znalazł ci klasy Config

0

Wiem, to wychodzi pomimo, ze w init.php mam
'''
?php

use Bookstore\Domain\Book;
use Bookstore\Domain\Customer;
use Bookstore\Domain\Premium;
use Bookstore\Domain\Payer;
use Bookstore\Domain\Basic;
use Bookstore\Domain\Person;
use Bookstore\Utils\Config;

'''
w Config.php

'''
<?php
namespace Bookstore\Utils;
use Bookstore\Utils\NotFoundException;
'''

Więc wygląda, ze wszystko sie zgadza?

1 użytkowników online, w tym zalogowanych: 0, gości: 1, botów: 0