laravel
laravel copied to clipboard
Method Illuminate\Database\PostgresConnection::getDoctrineSchemaManager does not exist
- Set up empty laravel project
- Config PostgreSQL database
- Create sample table
- try
php artisan code:models --table=your_sample_table
Get error:
BadMethodCallException
Method Illuminate\Database\PostgresConnection::getDoctrineSchemaManager does not exist.
at vendor\laravel\framework\src\Illuminate\Macroable\Traits\Macroable.php:115
111▕ */
112▕ public function __call($method, $parameters)
113▕ {
114▕ if (! static::hasMacro($method)) {
➜ 115▕ throw new BadMethodCallException(sprintf(
116▕ 'Method %s::%s does not exist.', static::class, $method
117▕ ));
118▕ }
1 vendor\reliese\laravel\src\Meta\Postgres\Schema.php:286
Illuminate\Database\Connection::__call("getDoctrineSchemaManager", [])
2 [internal]:0
Reliese\Meta\Postgres\Schema::schemas(Object(Illuminate\Database\PostgresConnection))
My way to fix this:
in src/Meta/Postgres/Schema.php
or vendor/reliese/laravel/src/Meta/Postgres/Schema.php
in method public static function schemas(Connection $connection)
change from
public static function schemas(Connection $connection)
{
$schemas = $connection->getDoctrineSchemaManager()->listDatabases();
return array_diff($schemas, [
'postgres',
'template0',
'template1',
]);
}
to this
public static function schemas(Connection $connection)
{
$schemas = array_column($connection->getSchemaBuilder()->getTables(), 'name');
return array_diff($schemas, [
'postgres',
'template0',
'template1',
]);
}
- Set up empty laravel project
- Config PostgreSQL database
- Create sample table
- try
php artisan code:models --table=your_sample_tableGet error:
BadMethodCallException Method Illuminate\Database\PostgresConnection::getDoctrineSchemaManager does not exist. at vendor\laravel\framework\src\Illuminate\Macroable\Traits\Macroable.php:115 111▕ */ 112▕ public function __call($method, $parameters) 113▕ { 114▕ if (! static::hasMacro($method)) { ➜ 115▕ throw new BadMethodCallException(sprintf( 116▕ 'Method %s::%s does not exist.', static::class, $method 117▕ )); 118▕ } 1 vendor\reliese\laravel\src\Meta\Postgres\Schema.php:286 Illuminate\Database\Connection::__call("getDoctrineSchemaManager", []) 2 [internal]:0 Reliese\Meta\Postgres\Schema::schemas(Object(Illuminate\Database\PostgresConnection))My way to fix this:
in
src/Meta/Postgres/Schema.phporvendor/reliese/laravel/src/Meta/Postgres/Schema.phpin method
public static function schemas(Connection $connection)change from
public static function schemas(Connection $connection) { $schemas = $connection->getDoctrineSchemaManager()->listDatabases(); return array_diff($schemas, [ 'postgres', 'template0', 'template1', ]); }to this
public static function schemas(Connection $connection) { $schemas = array_column($connection->getSchemaBuilder()->getTables(), 'name'); return array_diff($schemas, [ 'postgres', 'template0', 'template1', ]); }
This Actually worked!! Thanks alot.
May the team build this amazing plugin update thier code, since laravel 11 removed the support for getDoctrineSchemaManager