PDOConnection.php第24行中的FatalThrowableError错误Laravel 5.3

时间:2019-01-08 10:11:35

标签: php mysql laravel pdo connection

尝试登录时收到消息。 一切都很好。 我检查了与数据库的连接,并检查了MySQL服务器是否正常工作。

FatalThrowableError in PDOConnection.php line 24:
Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE)

in PDOConnection.php line 24
at Composer\Autoload\includeFile('/var/www/html/vendor/composer/../doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php') in ClassLoader.php line 322
at ClassLoader->loadClass('Doctrine\DBAL\Driver\PDOConnection')
at spl_autoload_call('Doctrine\DBAL\Driver\PDOConnection')
at class_exists('Doctrine\DBAL\Driver\PDOConnection') in Connector.php line 115
at Connector->createPdoConnection('mysql:host=127.0.0.1;port=3306;dbname=fuckerbot', 'root', '****', array('0', '2', '0', false, false)) in Connector.php line 56
at Connector->createConnection('mysql:host=127.0.0.1;port=3306;dbname=fuckerbot', array('driver' => 'mysql', 'host' => '127.0.0.1', 'port' => '3306', 'database' => 'fuckerbot', 'username' => 'root', 'password' => '*****', 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'strict' => false, 'engine' => null, 'name' => 'mysql'), array('0', '2', '0', false, false)) in MySqlConnector.php line 24
at MySqlConnector->connect(array('driver' => 'mysql', 'host' => '127.0.0.1', 'port' => '3306', 'database' => 'fuckerbot', 'username' => 'root', 'password' => '*****', 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'strict' => false, 'engine' => null, 'name' => 'mysql')) in ConnectionFactory.php line 126
at ConnectionFactory->Illuminate\Database\Connectors\{closure}()
at call_user_func(object(Closure)) in Connection.php line 965
at Connection->getPdo() in Connection.php line 986
at Connection->getReadPdo() in Connection.php line 423
at Connection->getPdoForSelect(true) in Connection.php line 333
at Connection->Illuminate\Database\{closure}(object(MySqlConnection), 'select * from `users` where `email` = ? limit 1', array('admin@admin.ru')) in Connection.php line 763
at Connection->runQueryCallback('select * from `users` where `email` = ? limit 1', array('admin@admin.ru'), object(Closure)) in Connection.php line 726
at Connection->run('select * from `users` where `email` = ? limit 1', array('admin@admin.ru'), object(Closure)) in Connection.php line 351
at Connection->select('select * from `users` where `email` = ? limit 1', array('admin@admin.ru'), true) in Builder.php line 1648
at Builder->runSelect() in Builder.php line 1634
at Builder->get(array('*')) in Builder.php line 638
at Builder->getModels(array('*')) in Builder.php line 327
at Builder->get(array('*')) in Builder.php line 297
at Builder->first() in EloquentUserProvider.php line 104
at EloquentUserProvider->retrieveByCredentials(array('email' => 'admin@admin.ru', 'password' => '*****')) in SessionGuard.php line 353
at SessionGuard->attempt(array('email' => 'admin@admin.ru', 'password' => '*******'), false) in AuthenticatesUsers.php line 76
at LoginController->attemptLogin(object(Request)) in AuthenticatesUsers.php line 42
at LoginController->login(object(Request))
at call_user_func_array(array(object(LoginController), 'login'), array(object(Request))) in Controller.php line 55
at Controller->callAction('login', array(object(Request))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(LoginController), 'login') in Route.php line 189
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 653
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in RedirectIfAuthenticated.php line 24
at RedirectIfAuthenticated->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 655
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 53

这是错误消息中的所有堆栈跟踪。我找不到并从我的代码中指出了要点。在本地系统上的一分钟,它的项目正常工作。但是远程服务器出现错误。

2 个答案:

答案 0 :(得分:0)

Laravel 5.3实际上需要5.6.4到7.1。*之间的PHP版本,并且您已对其进行了更改,也许您未安装PHP 7.0否未激活此处https://laravel.com/docs/5.3/installation列出的正确扩展? >

答案 1 :(得分:0)

错误发生在this line

public function __construct($dsn, $user = null, $password = null, ?array $options = null)

特别是在?之前的问号array $options上。

这是new feature,在PHP v7.1中引入,称为Nullable类型。

您必须使用7.1版或更高版本,此错误才能消失。