i was learning laravel6 from scratch from laracast.com and when i started to use the database. I bumped into the following problem:
IlluminateDatabaseQueryException could not find driver (SQL: select
* fromposts
whereslug
= my-first-post limit 1)
I use wamp with phpmyadmin. I tried xamp and mySQL workbench. I updated my dependencies, but without result.
this is my controller:
<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
class PostsController extends Controller
{
public function show($slug)
{
$post = DB::table('posts')->where('slug', $slug)->first();
if(! $post){
abort(404);
}
return view('post', [
'post' => $post
]);
}
}
Can somebody please help me with this problem?
Best regards,
Jeff
2
Answers
When i installed composer. I needed to assign the location of my php.exe. This field was empty so i installed php when i already had wampp installed.
Solution: I uninstalled wampp, composer and deleted php. I started over and installed xampp first. When i wanted to install composer. It immediately suggested php.exe in my xampp folder. After installing laravel the problem was solved.
Conclusion: Composer installation went wrong. Since i had multiple php's in my system i probably assignt composer to the wrong one.
Thanks for your help.
Are you insert DB in namespace