调用未定义的方法照明 database schema blueprint :: enablePostgis()



我正在尝试设置Laravel应用程序。我确保使用啤酒安装了tostgis:

$ brew install postgis
Warning: postgis 2.3.2 is already installed

,我知道它已经被列为composer.json中所需的软件包之一:

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

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

但是,当我运行php artisan migrate时,我会得到这个

[SymfonyComponentDebugExceptionFatalThrowableError]
  Call to undefined method IlluminateDatabaseSchemaBlueprint::enablePostgis()

我的代码看起来像这样

use IlluminateDatabaseSchemaBlueprint;
use IlluminateDatabaseMigrationsMigration;
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

不确定发生了什么?

替换

use IlluminateDatabaseSchemaBlueprint;

use PhazaLaravelPostgisSchemaBlueprint;

您是否尝试过仅将EG $table->point('location')放入function up() 中,而没有$table->enablePostgis()

在示例迁移中,在文档中,任何地方都没有$table->enablePostgis()语句。

事实证明,我的Postgres DB连接详细信息(即用户名/PWD)不正确!因此,这与导入库无关。.因此,错误消息是如此误导。对不起,(

最新更新