2

I deployed my Laravel 4.1 app in Heroku by following this article http://phpartisan.tumblr.com/post/71580870739/running-laravel-4-on-heroku

The static HTML homepage loaded okay but when I am trying to log-in, I am getting the error

SQLSTATE[HY000] [2002] No such file or directory 

My local setup is Laravel 4.1 & MySQL.

I don't think there was a database created when I deployed.

Do I need to do it manually? How and what will be my settings then?

thanks!

RodM
  • 426
  • 1
  • 5
  • 19
  • Do you have mysql set up on your server? – Elliot Fehr Apr 19 '14 at 14:43
  • Possible duplicate of [PDOException SQLSTATE\[HY000\] \[2002\] No such file or directory](http://stackoverflow.com/questions/20723803/pdoexception-sqlstatehy000-2002-no-such-file-or-directory) – Potherca Oct 31 '15 at 15:58

1 Answers1

0

The problem could be your environment might still point to local. in cli, type heroku run php artisan env to find out.

else, you might wanto run php artisan migrate --env=production to set it to the correct production environment.

you might then encounter another issue like this:

PHP Fatal error: Call to undefined function Symfony\Component\Console\mb_convert_variables() in /var/www/mysite/vendor/symfony/console/Symfony/Component/Console/Application.php on line 1154

Trust me, tt has nothing to do with mb_string module like what this post stated. Laravel: Call to undefined function Symfony\Component\Console\mb_convert_variables()?

The problem is at environment setting.

First, make sure you have .env.php file at same dir level with composer.json and it is exists in your heroku instance. Since you cant FTP inside, you need to push to repo. But laravel tell you this is git ignored, so you will need to temporary allow it to push to your heroku repo.

Next, you will need to edit the bootstrap\start.php

replace the $env = $app->detectEnvironment(function(){}) to:

$env = $app->detectEnvironment(function() { return file_exists(dirname(__FILE__) . '/../.env.php') ? 'production' : 'local'; }); Once you done all these, rerun the migrate command and it will works.

You may follow this link for reference. Laravel environment config not loading, migration fails - SQLSTATE[HY000] [2002] No such file or directory

Community
  • 1
  • 1
exiang
  • 559
  • 2
  • 14