php - Slim framework project error -
i've created new project:

project tree can see @ right of screen , database @ left.
my home.php file:
<?php $app->get('/',function() use($app) { $posts = $app->db->query(" select posts.* posts left join users on posts.pauthor = users.id; ")->fetchall(pdo::fetch_assoc); var_dump($posts); die(); })->name('home'); my index.html file:
<?php require '../app/start.php'; my routes.php file:
<?php require 'routes/home.php'; my start.php(main app file):
<?php require '../vendor/autoload.php'; $app = new \slim\slim(); // database $app->container->singleton('db',function(){ return new pdo('mysql:127.0.0.1;dbname=blog','root',''); }); require 'routes.php'; $app->run(); and after trying open project had error occured:

is there wrong? i'm following lesson: https://www.youtube.com/watch?v=srfygco3xo4(not pr).
is there wrong?
yes. if copy-paste something, right.. forgot host while initialize pdo.
$app->container->singleton('db',function(){ return new pdo('mysql:host=127.0.0.1;dbname=blog','root',''); });
Comments
Post a Comment