SQLiteConnector.php中的InvalidArgumentException:数据库(storage / database.sqlite)不存在

时间:2016-05-16 08:59:09

标签: database sqlite laravel exception

我最近开始探索Laravel,我的目标是建立一个具有基本CRUD功能的简单网站。所以这里的上下文是我希望能够显示页面中所有条目的列表,但是当我创建该索引页面时,遇到以下异常:

    InvalidArgumentException in SQLiteConnector.php line 34:
    Database (storage/database.sqlite) does not exist.
    in SQLiteConnector.php line 34
    at SQLiteConnector->connect(array('driver' => 'sqlite', 'database' => 'storage/database.sqlite', 'prefix' => '', 'name' => 'sqlite')) in ConnectionFactory.php line 61
    at ConnectionFactory->Illuminate\Database\Connectors\{closure}()
    at call_user_func(object(Closure)) in Connection.php line 868
    at Connection->getPdo() in Connection.php line 736
    at Connection->reconnectIfMissingConnection() in Connection.php line 621
    at Connection->run('select * from "certificates"', array(), object(Closure)) in Connection.php line 342
    at Connection->select('select * from "certificates"', array(), true) in Builder.php line 1515
    at Builder->runSelect() in Builder.php line 1501
    at Builder->get(array('*')) in Builder.php line 596
    at Builder->getModels(array('*')) in Builder.php line 303
    at Builder->get(array('*')) in Model.php line 646
    at Model::all() in certificatesController.php line 15
    at CertificatesController->index()
    at call_user_func_array(array(object(CertificatesController), 'index'), array()) in Controller.php line 80
    at Controller->callAction('index', array()) in ControllerDispatcher.php line 146
    at ControllerDispatcher->call(object(CertificatesController), object(Route), 'index') in ControllerDispatcher.php line 94
    at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
    at Pipeline->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
    at ControllerDispatcher->callWithinStack(object(CertificatesController), object(Route), object(Request), 'index') in ControllerDispatcher.php line 54
    at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\certificatesController', 'index') in Route.php line 174
    at Route->runController(object(Request)) in Route.php line 140
    at Route->run(object(Request)) in Router.php line 724
    at Router->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
    at VerifyCsrfToken->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in         ShareErrorsFromSession.php line 49
    at ShareErrorsFromSession->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
    at StartSession->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
    at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
    at EncryptCookies->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
    at Pipeline->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in Router.php line 726
    at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
    at Router->dispatchToRoute(object(Request)) in Router.php line 675
    at Router->dispatch(object(Request)) in Kernel.php line 246
    at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
    at CheckForMaintenanceMode->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
    at Pipeline->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in Kernel.php line 132
    at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
    at Kernel->handle(object(Request)) in index.php line 54

Stackoverflow上提出的类似问题的解决方案对我不起作用。基本上,这些是我的.env和config / database.php文件中的内容:

.ENV

    DB_CONNECTION=sqlite
    DB_HOST=localhost
    DB_PORT=8888
    DB_DATABASE=storage/database.sqlite

配置/ database.php中

'default' => env('DB_CONNECTION', 'sqlite'),
'sqlite' => [
             'driver' => 'sqlite',
             'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
            ],

我在本地运行(而不是Homestead)并且我一直在尝试多次更改不同的值(例如,使用绝对路径,在3306和8888之间切换端口号)。如果有人可以就如何解决这个问题提供一些建议,我们将非常感激:)

谢谢!

1 个答案:

答案 0 :(得分:0)

错误消息显示没有storage/database.sqlite请确保您在存储文件夹中创建一个空文本文件,并将其命名为database.sqlite,然后运行php artisan migrate < / p>