Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Symfony 6/Laravel 9 #128

Merged
merged 3 commits into from
Jan 14, 2022
Merged

Add support for Symfony 6/Laravel 9 #128

merged 3 commits into from
Jan 14, 2022

Conversation

wouterj
Copy link
Owner

@wouterj wouterj commented Dec 26, 2021

Laravel 9 is the first version that comes with support for Symfony 6 and is expected to be released in January.

@wouterj wouterj force-pushed the laravel9-sf6 branch 2 times, most recently from 7835e6e to dbf0c8b Compare January 7, 2022 09:38
@Broutard
Copy link

Broutard commented Jan 7, 2022

Hi,

When running make:eloquent-migration create_base_table got:

Too few arguments to function Illuminate\Database\Migrations\MigrationCreator::firePostCreateHooks(), 1 passed in /opt/app/src/vendor/wouterj/eloquent-bundle/src/Migrations/Creator.php on line 43 and exactly 2 expected

@Broutard
Copy link

Broutard commented Jan 7, 2022

When running eloquent:migrate got:

Call to a member function getRequire() on null

Since Laravel8, we have to extends resolvePath() method in Migrator class also to avoid $migration = $this->files->getRequire($path); call.

/**
     * Resolve a migration instance from a migration path.
     *
     * @param  string  $path
     * @return object
     */
    protected function resolvePath(string $path)
    {
        $class = $this->getMigrationClass($this->getMigrationName($path));

        if (class_exists($class) && realpath($path) == (new ReflectionClass($class))->getFileName()) {
            return new $class;
        }

        $migration = require $path;

        return is_object($migration) ? $migration : new $class;
    }
    ```

@wouterj
Copy link
Owner Author

wouterj commented Jan 14, 2022

Hi @Broutard. Thank you for testing out this PR! I've tried to fix your first comment.

If I'm understand your second comment correctly, this is also a bug in the current release of this bundle? If so, could you maybe sent a new PR with a fix? (and if possible a test case for the fix) Thank you! :)

@wouterj wouterj force-pushed the laravel9-sf6 branch 2 times, most recently from e791b84 to 58c7040 Compare January 14, 2022 17:32
@wouterj wouterj marked this pull request as ready for review January 14, 2022 17:34
@wouterj wouterj merged commit 29b9862 into 2.x Jan 14, 2022
@wouterj wouterj deleted the laravel9-sf6 branch January 14, 2022 17:37
@Broutard
Copy link

@wouterj for the 2nd, the bug should appear also with Laravel8 (not tested)

@fd6130
Copy link

fd6130 commented Jan 23, 2022

So we will have a new release version of this bundle after Larevel 9 is released?

@wouterj
Copy link
Owner Author

wouterj commented Jan 23, 2022

Yes, I'm trying to keep up with Laravel releases. Depending on the available time, a new version will be released in the days/weeks after the Laravel release.

@g-ra
Copy link

g-ra commented Jun 7, 2023

which news guys ? i have same error

@g-ra
Copy link

g-ra commented Jun 7, 2023

Here is my fix code

in Service

namespace App\Service;

use WouterJ\EloquentBundle\Migrations\Migrator as BaseMigrator;
use ReflectionClass;

class CustomMigrator extends BaseMigrator
{
protected function resolvePath(string $path)
{
$class = $this->getMigrationClass($this->getMigrationName($path));

    if (class_exists($class) && realpath($path) === (new ReflectionClass($class))->getFileName()) {
        return new $class;
    }

    $migration = require $path;

    return is_object($migration) ? $migration : new $class;
}

}

in eloquent.yaml
services: wouterj_eloquent.migrator: class: App\Service\CustomMigrator arguments: - '@wouterj_eloquent.migrations.repository' - '@wouterj_eloquent.database_manager'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants