reliese / laravel

Reliese Laravel Model Generator
MIT License
1.49k stars 316 forks source link

Laravel 11 support #273

Closed osama-98 closed 5 months ago

osama-98 commented 8 months ago

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))
uacode commented 8 months ago

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

Removes DB::getDoctrineSchemaManager() method

igun997 commented 8 months ago

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

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

osama-98 commented 8 months ago

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

uacode commented 8 months ago

@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',
        ]);
    }
igun997 commented 8 months ago

@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

vibonacci commented 7 months ago

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.

andreasdorfer commented 7 months ago

@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.

igun997 commented 7 months ago

@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

aavinseth commented 6 months ago

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

realitymatters commented 6 months ago

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

alexlpdj commented 5 months ago

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

finiteinfinity commented 5 months ago

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

ahmedK03 commented 4 months ago

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

cd-slash commented 2 months ago

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?

alfmateos commented 2 months ago

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!

tomasbreffitt commented 4 days ago

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.