1

Im trying to run a very basic Laravel app on my localhost.

I have a simple postgre DB, which contains 3 data rows. I can query the items in razorSQL and get the results, so the DB is fine.

In phpStorm I start a web server using php -S localhost:8888 -t public

Web server starts fine. If I start the app I get the Laravel home screen.

Okay, then I change the home route to this. I get "Hello World" displayed.

Route::get('/', function(){
    $data = "Hello World";
    return $data;
});

But when I do this

Route::get('/', function(){
    $data = \DB::table('posts')->get();
    return $data;
});

I get...

enter image description here

Do phpStorm support PDO or is ther some plugin that I need?

UPDATE

Route::get('/', function(){
//            $data = \DB::table('posts')->get();
    $data = phpinfo();
    return $data;
});

php.ini location
enter image description here

php.ini
enter image description here

So PDO is enabled in php.ini. This is what I dont get. And yes I am new to PHP.

here is the PDO snip from phpInfo() - PS, yes I did restart wamp after the change. I just dont understand why pdo_pgsql is not appearing/working

enter image description here

Its also active in the Dropdown php extensions
enter image description here

Fabio Antunes
  • 22,251
  • 15
  • 81
  • 96
morne
  • 4,035
  • 9
  • 50
  • 96
  • 7
    What this error has to do with PhpStorm (except the fact that you are using PhpStorm to write your code)? So far it looks like you have not enabled PDO driver/extension for Posgre in your php.ini. – LazyOne Apr 23 '15 at 10:19
  • 1
    possible duplicate of [PDOException “could not find driver”](http://stackoverflow.com/questions/2852748/pdoexception-could-not-find-driver) – Matheno Apr 23 '15 at 10:20
  • Im asking about phpStorm, as this is where I started the web server. So php.ini in porsgre. Where is this file located in the postgre file structure? – morne Apr 23 '15 at 10:24
  • *"Im asking about phpStorm, as this is where I started the web server."* And? This error is generated by PHP itself and not by PhpStorm. *"Where is this file located in the postgre file structure?"* Are you new to PHP? If yes then just say so. Because php.ini is part of PHP and not Postgre. – LazyOne Apr 23 '15 at 10:28
  • 1
    How did you get that `phpinfo()` output? It has to be done via the same way as your actual code (which means -- call it in your Laravel app) as it's possible that you have 2 different `php.ini` for CLI and Apache (the way how you started Laravel's web server is considered CLI) – LazyOne Apr 23 '15 at 10:38
  • @LazyOne, please elaborate. You tell me what things are supposed to be, but you dont go into much detail. Please can you just elaborate on this. I ran phpInfo() from laravel and that is what it came up with. Is that not the same php.ini file that Laravel uses then? – morne Apr 23 '15 at 10:41
  • If it's run from Laravel then it's the same. If that extension was enabled .. then it supposed to work (although I should not be considered as "pro" in this particular case as I'm not using Postgre myself -- only MySQL, SQL Server and SQLite (sometimes)). If you have enabled that extension just now -- make sure that you have restarted your web server (no `php.exe` or similar processes in Task Manager). Also -- you should have separate section with Postgre PDO current settings in `phpinfo()` output -- can you please list it as well? – LazyOne Apr 23 '15 at 10:48
  • As you can see -- the PDO driver for Postgre is not actually loaded. I suggest: 1) make sure that PHP logs errors into a log file 2) make sure that `display_startup_errors = On` in php.ini; 3) Try `php -i` in console -- it may provide more details. As it stands right now it could be that PDO driver for Postgre is unable to find some library which it needs to be able to communicate with actual Postgre DB server (had such kind of errors long time ago (3-5 years or so) with MySQL) – LazyOne Apr 23 '15 at 10:58
  • **FYI:** Please note that using `php -S localhost:8888 -t public` means that page (e.g. `http://localhost:8888/index.php`) will be served by PHP's own simple server directly and not by your Apache from WAMP. – LazyOne Apr 23 '15 at 11:01
  • @LazyOne. This "simple server". wont this also have a php.ini file then? Maybe I should opt for `homestead` instead, but I would like to solve this problem. Thanks for the heads-up though. – morne Apr 23 '15 at 11:07
  • As I have stated in my 3rd comment -- it could be (not using WAMP myself). But you have said that you have captured `phpinfo()` using it .. so it should represent correct path to php.ini already . In any case: `php -i` in console and see what file it uses. P.S. I believe that `homestead` would be the best choice overall (as in this case it will be running in separate VM and not messing with your host OS (Windows)) – LazyOne Apr 23 '15 at 11:20
  • Forget about WAMP and phpStorm, neither has anything to do with your problem. You are invoking php from the command line, you need to find out what php.ini is actually used (@LazyOne has already told you how to do that). Once you find that out, then all you need to do is what you would have done if you were editing WAMP's php.ini. – yannis Apr 23 '15 at 11:42
  • cant explain it, but its fixed. CLI and WAMP where using the same `php.ini` file anyways. If I learn more about `httpd.conf`, maybe I will understand in the future. Thanks all for the help. – morne Apr 23 '15 at 12:32

1 Answers1

2

Finaly resoved it, but will use HOMESTEAD anyways, but here is the solution.

WAMP and php CLI where both using the same php.ini file.
But I came across this solution and it worked.

You just have to add this lines into the httpd.conf

PHPIniDir "Full path to your PHP directory/"
Loadfile "Full path to your PHP directory/php5ts.dll"
Loadfile "Full path to your PHP directory/libpq.dll"
LoadModule php5_module "Full path to your PHP directory/php5apache2_4.dll"

save httpd.conf

Exit WAMP

Then in cmd do

net stop dnscache
net start dnscache

then

Restart WAMP

So it looks like this in the end

#This was activated on 23/04/2015
LoadFile "H:/wamp/bin/php/php5.5.12/php5ts.dll"
LoadFile "H:/wamp/bin/php/php5.5.12/libpq.dll"
PHPIniDir h:/wamp/bin/php/php5.5.12/
LoadModule php5_module "h:/wamp/bin/php/php5.5.12/php5apache2_4.dll"
morne
  • 4,035
  • 9
  • 50
  • 96