2016-03-28 9 views
1

Laracasts'te Çizelge Laravel 5'i takip ediyorum ve özel olarak "Veri Alınıyor" dersini okudum.SQLiteConnector.php satırında InvalidArgumentException 34: Veritabanı (homestead) mevcut değil

Veritabanı.sqlite dosyasını oluşturdum, tinker'dan bazı veriler ekledim ve bunları konsolda alabildim. Ardından, videonun ne yaptığını çoğaltmaya çalışıyorum.

Kartlarım kontrolörü: Ancak

<?php 

namespace App\Http\Controllers; 

use Illuminate\Http\Request; 
use App\Http\Controllers\Controller; 

use App\Http\Requests; 

class CardsController extends Controller 
{ 
    public function index() 
    { 
     $cards = \DB::table('cards')->get(); 
     return view('cards.index', compact('cards')); 
    } 
} 

, ben şu hatayı var/kartları rotayı yüklemeyi deneyin

InvalidArgumentException in SQLiteConnector.php line 34: 
Database (homestead) does not exist. 

Bu benim env dosyasıdır

APP_ENV=local 
APP_DEBUG=true 
APP_KEY=base64:P3ZgRMRkb2e8+x7S9rDLLB+bKJdR5Unpj8zXBUIHIZE= 
APP_URL=http://localhost 

DB_CONNECTION=sqlite 
DB_FILE=database.sqlite 


CACHE_DRIVER=file 
SESSION_DRIVER=file 
QUEUE_DRIVER=sync 

REDIS_HOST=127.0.0.1 
REDIS_PASSWORD=null 
REDIS_PORT=6379 

MAIL_DRIVER=smtp 
MAIL_HOST=mailtrap.io 
MAIL_PORT=2525 
MAIL_USERNAME=null 
MAIL_PASSWORD=null 
MAIL_ENCRYPTION=null 

cevap

2

Hatanızda başvurulan satırın altında, şudur:

// Here we'll verify that the SQLite database exists before going any further 
    // as the developer probably wants to know if the database exists and this 
    // SQLite driver will not throw any exception if it does not by default. 
    if ($path === false) { 
     throw new InvalidArgumentException("Database (${config['database']}) does not exist."); 
    } 

Yöntemin yukarısındaki yoruma bakarak, yolunuzun doğru şekilde ayarlanmadığı anlaşılıyor. Doğru ortam değişkeni olması gerektiğine inanıyoruz:

DB_DATABASE=database/database.sqlite

yerine

DB_FILE=database/database.sqlite

Değilse, config/database.php dosyayı kontrol ve bu bölüm için bakın:

'sqlite' => [ 
     'driver' => 'sqlite', 
     'database' => env('DB_DATABASE', database_path('database.sqlite')), // this line! 
     'prefix' => '', 
    ], 
1

Ben de fark ettim ki (en azından bir Mac üzerinde 5.2.29 Laravel sürümünde) yolun mutlak bir p olması gerekir. ath. Tuhaf olan şey, geçişleri çalıştırmak için göreceli bir yol çalışacak, ancak uygulama o zaman DB'ye erişmeye çalışırken o zaman başarısız oluyor.