【问题标题】:Issue running php laravel application - Google App Engine运行 php laravel 应用程序的问题 - Google App Engine
【发布时间】:2019-07-18 07:11:34
【问题描述】:

我有一个带有 PHP Laravel 前端和 Postgress SQL 后端的 Web 应用程序。我已将此应用程序部署到 google app engine flex 环境。部署到应用引擎后,从站点登录后出现以下错误。登录后,当将数据库指向谷歌云 SQL postgress 数据库时,应用程序在我的本地环境中运行良好。

 Error:   
 count(): Parameter must be an array or an object that implements Countable
    in 57369c716dc79e4b8bf3c1b292b0f7eb440a33da.php line 35
    at HandleExceptions->handleError('2', 'count(): Parameter must be an array or an object that implements Countable', '/app/storage/framework/views/57369c716dc79e4b8bf3c1b292b0f7eb440a33da.php', '35', array('__path' => '/app/storage/framework/views/57369c716dc79e4b8bf3c1b292b0f7eb440a33da.php', '__data' => array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'obLevel' => '2', 'data' => object(stdClass)), 'obLevel' => '3', '__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'data' => object(stdClass))) in 57369c716dc79e4b8bf3c1b292b0f7eb440a33da.php line 35

这是我的 app.yaml 文件

runtime: php
env: flex

runtime_config:
  document_root: public


skip_files:
  - .env   


env_variables:
  # Put production environment variables here.
  APP_LOG: errorlog
  APP_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxx
  STORAGE_DIR: /tmp
  DB_DRIVER: 'pgsql'
  DB_CONNECTION: pgsql
  DB_HOST: <ipaddress of cloud sql db>
  DB_PORT: 5432
  DB_DATABASE: dbname
  DB_USERNAME: xxxxxxx
  DB_PASSWORD: xxyyzz
  DB_SOCKET: "/cloudsql/xxx:xyz:yxz"
  REDIS_HOST: localhost
  REDIS_PASSWORD : null
  REDIS_PORT: 6379

beta_settings: 
  cloud_sql_instances: "xyz:xyzz:instance=tcp:5432" 

【问题讨论】:

  • 可能是您从本地开发环境中复制了一些文件,您只需要使用php artisan view:clearphp artisan cache:clear 清除视图和缓存。如果您无法运行控制台命令,则只需删除storage/framework/views/中的所有文件

标签: php laravel postgresql google-app-engine google-cloud-platform


【解决方案1】:

这个错误听起来很像 Google App Engine 正在运行 PHP 7.2+,而您的代码与它不兼容。 7.2 对 count() 函数的语义进行了一些更改,因此请查看此更改,特别是您自己对函数的使用情况,以确认它被正确使用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-12
    • 2016-12-28
    • 2013-12-20
    • 2016-03-11
    • 1970-01-01
    • 2019-02-28
    相关资源
    最近更新 更多