mercredi 16 décembre 2015

Laravel with XAMPP mysql: SQLSTATE[HY000] [2002] No such file or directory

I am trying to use the XAMPP mysql database with laravel 5.

When I do: php artisan migrate, a couple of tables are created in my database.

In my database I have a customer table, with two records. Now I want to get the record with id=1. So I created the customer.php and added a route to route.php. However, when I go to http://localhost:8000/customer. I get this error:

PDOException in Connector.php line 55:

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

What am I doing wrong?

.env

APP_ENV=local
APP_DEBUG=true
APP_KEY=cLXy8IWNoSzzkQJ6AOM26bpteRm7EDoZ

DB_HOST=127.0.0.1
DB_DATABASE=test1
DB_USERNAME=root
DB_PASSWORD=

routes.php

Route::get('customer', function(){
  $customer = App\Customer::find(1);
  print_r($customer);
});

Customer.php

<?php
namespace App;

use Illuminate\Database\Eloquent\Model;

class Customer extends Model {

}
?>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire