【问题标题】:Call to undefined method Illuminate\Database\Schema\Blueprint::enablePostgis()调用未定义的方法 Illuminate\Database\Schema\Blueprint::enablePostgis()
【发布时间】:2017-09-28 12:32:34
【问题描述】:

我正在尝试设置 Laravel 应用程序。我确保我使用 brew 在我的系统上安装了 postgis:

$ brew install postgis
Warning: postgis 2.3.2 is already installed

我知道它已经被列为composer.json 中的必需包之一,如下所示:

"phaza/laravel-postgis": "^3.0",

我也可以在我的composer.lock 中找到它。

但是当我运行php artisan migrate 时,我明白了

[Symfony\Component\Debug\Exception\FatalThrowableError]
  Call to undefined method Illuminate\Database\Schema\Blueprint::enablePostgis()

我的代码看起来像这样

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            ...
            $table->enablePostgis();

如果我点击enablePostgis 上的跳转到定义,它会将我带到这里:

vendor/phaza/laravel-postgis/src/Schema/Blueprint.php

不确定发生了什么?

【问题讨论】:

    标签: php database symfony postgis


    【解决方案1】:

    替换

    use Illuminate\Database\Schema\Blueprint;
    

    use Phaza\LaravelPostgis\Schema\Blueprint;
    

    【讨论】:

      【解决方案2】:

      您是否尝试过仅将 $table->point('location') 放入 function up() 而不使用 $table->enablePostgis()

      the documentation 的示例迁移中,任何地方都没有$table->enablePostgis() 语句。

      【讨论】:

      • 哦 - 我建议你也按照 @cthulu 的评论修复 use 声明。
      【解决方案3】:

      原来我的 postgres 数据库连接详细信息(即用户名/密码)不正确!所以它与导入库无关..所以错误消息太误导了..对不起各位:(

      【讨论】:

        猜你喜欢
        • 2014-12-11
        • 1970-01-01
        • 2017-06-25
        • 2022-12-21
        • 2021-12-30
        • 2021-04-12
        • 1970-01-01
        • 2019-09-28
        • 2014-04-23
        相关资源
        最近更新 更多