laravel icon indicating copy to clipboard operation
laravel copied to clipboard

Laravel 11 support

Open osama-98 opened this issue 1 year ago • 10 comments

I got an error when I did update to Laravel11, please find the error message


   BadMethodCallException 

  Method Illuminate\Database\MySqlConnection::getDoctrineSchemaManager does not exist.

  at vendor\laravel\framework\src\Illuminate\Macroable\Traits\Macroable.php:112
    108▕      */
    109▕     public function __call($method, $parameters)
    110▕     {
    111▕         if (! static::hasMacro($method)) {
  ➜ 112▕             throw new BadMethodCallException(sprintf(
    113▕                 'Method %s::%s does not exist.', static::class, $method
    114▕             ));
    115▕         }
    116▕

  i   Bad Method Call: Did you mean Illuminate\Database\MySqlConnection::getSchemaGrammar() ?

  1   vendor\reliese\laravel\src\Meta\MySql\Schema.php:273
      Illuminate\Database\Connection::__call("getDoctrineSchemaManager", [])

  2   [internal]:0
      Reliese\Meta\MySql\Schema::schemas(Object(Illuminate\Database\MySqlConnection))

osama-98 avatar Mar 15 '24 20:03 osama-98

https://github.com/laravel/framework/pull/48864

Removes DB::getDoctrineSchemaManager() method

uacode avatar Mar 17 '24 18:03 uacode

you can modify like this , it cause doctrine types not supported on laravel 11

https://github.com/reliese/laravel/pull/208

igun997 avatar Mar 19 '24 22:03 igun997

@uacode This is explaining why the error is being thrown. But, how to solve it?

osama-98 avatar Mar 24 '24 09:03 osama-98

@osama-98 I commented in vendor (only for run DB migrations)

\Reliese\Meta\MySql\Schema::schemas

public static function schemas(Connection $connection)
    {
//        $schemas = $connection->getDoctrineSchemaManager()->listDatabases();
//        Schema::getDatabases();
        $schemas = [];

        return array_diff($schemas, [
            'information_schema',
            'sys',
            'mysql',
            'performance_schema',
        ]);
    }

uacode avatar Mar 24 '24 10:03 uacode

@uacode This is explaining why the error is being thrown. But, how to solve it?

I resolved it on PR #208 you can direct edit your vendor folder

igun997 avatar Mar 24 '24 10:03 igun997

Could somebody please review and merge? New Laravel devs cannot use this as they start with Laravel 11 and will be forced to make their own Model files: 1 for each table.

vibonacci avatar Apr 16 '24 20:04 vibonacci

@igun997 Your PR doesn't fix the issue completely. There are still calls to the getDoctrineSchemaManager (in ...Postgres/Schema.php) which was removed in v11.

andreasdorfer avatar Apr 21 '24 17:04 andreasdorfer

@igun997 Your PR doesn't fix the issue completely. There are still calls to the getDoctrineSchemaManager (in ...Postgres/Schema.php) which was removed in v11.

ah , i forget about it. coz i use mysql & mariadb as primary databases

igun997 avatar Apr 21 '24 18:04 igun997

any update on this? as still I am getting the Method Illuminate\Database\MySqlConnection::getDoctrineSchemaManager does not exist. error while runing the php artisan code:models command

aavinseth avatar May 11 '24 07:05 aavinseth

any update on this? as still I am getting the Method Illuminate\Database\MySqlConnection::getDoctrineSchemaManager does not exist. error while runing the php artisan code:models command

Look a couple of comments back, this workaround works.

https://github.com/reliese/laravel/issues/273#issuecomment-2016756918

realitymatters avatar May 13 '24 14:05 realitymatters

any update on this? as still I am getting the Method Illuminate\Database\MySqlConnection::getDoctrineSchemaManager does not exist. error while runing the php artisan code:models command

same error here

alexlpdj avatar Jun 02 '24 15:06 alexlpdj

This should be resolved by #208. Apologies on the delay in getting this merged.

finiteinfinity avatar Jun 06 '24 14:06 finiteinfinity

Still Facing the Same issue with laravel 11, sqlite and php 8.2

ahmedK03 avatar Jul 26 '24 03:07 ahmedK03

Still seeing the same issue also with sqlite (PHP 8.3 and Laravel 11) - the workaround shown above appears to be for MySQL not sqlite. Is there a workaround for SQLite?

cd-slash avatar Aug 29 '24 10:08 cd-slash

Hi Guys, here is how to fix the problem with Postgres: 1.- go to this folder: vendor/reliese/laravel/src/Meta/Postgres and edit the file Schema.php 2.- edit the function "schemas" with this change:

public static function schemas(Connection $connection)
{
    // $schemas = $connection->getDoctrineSchemaManager()->listDatabases();
    $schemas = $connection->select('SELECT schema_name FROM information_schema.schemata');
    $schemas = array_column($schemas, 'schema_name');

    return array_diff($schemas, [
        'postgres',
        'template0',
        'template1',
    ]);
}

3.- save this file and run the command php artisan code:models again.

You are all set, that's it!

alfmateos avatar Sep 10 '24 10:09 alfmateos

Editing a vendor file is not a fix. I was using this method to get indexes on a table. I will need to find a new way.

tomasbreffitt avatar Nov 18 '24 18:11 tomasbreffitt