workarround for stof_doctrine_extensions

I have installed symfony 5 and doctrine 3.

I’m trying to implement automatic slug

According https://symfonycasts.com/screencast/symfony5-upgrade/stof-doctrine-extensions for symfony 5 I installed stof/doctrine-extensions-bundle. If I run composer show I get stof/doctrine-extensions-bundle v1.5.0 Integration of the gedmo/doctrine-extensio…

My composer.json

{
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "dev",
    "prefer-stable": true,
    "require": {
        "php": ">=7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "composer/package-versions-deprecated": "1.11.99.1",
        "doctrine/annotations": "^1.11",
        "doctrine/doctrine-bundle": "^2.2",
        "doctrine/doctrine-migrations-bundle": "^3.0",
        "doctrine/orm": "^2.8",
        "gedmo/doctrine-extensions": "^2.3.4 || ^[email protected]",
        "sensio/framework-extra-bundle": "^5.6",
        "stof/doctrine-extensions-bundle": "^1.5",
        "symfony/asset": "5.2.*",
        "symfony/console": "5.2.*",
        "symfony/dotenv": "5.2.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "5.2.*",
        "symfony/framework-bundle": "5.2.*",
        "symfony/maker-bundle": "^1.25",
        "symfony/options-resolver": "5.2.*",
        "symfony/security-bundle": "5.2.*",
        "symfony/twig-bundle": "5.2.*",
        "symfony/validator": "5.2.*",
        "symfony/yaml": "5.2.*",
        "twig/extra-bundle": "^2.12|^3.0",
        "twig/twig": "^2.12|^3.0"
    },
    "require-dev": {
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "AppTests": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.2.*"
        }
    }
}

I activate by
config/packages/stof_doctrine_extensions.yaml

stof_doctrine_extensions:
    default_locale: en_US
    orm:
        default:
            sluggable: true

My entity:

/**

  • @ORMColumn(type="string", length=100, unique=true)
  • @GedmoSlug(fields={"title"})
    */
    private $slug;

My controller:

$form = $this->createForm(ArticleFormType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
    $article = $form->getData();
    $em->persist($article);
    $em->flush();

When I submit the form, slug has a null value for that reason I get

An exception occurred while executing ‘INSERT INTO article (title, slug, content, published_at, heart_count, image_filename, created_at, updated_at, author_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)’ with params ["afdsfadsfads", null, "dsfdsfadsf", null, 0, null, "2020-12-08 16:32:55", "2020-12-08 16:32:55", 43]:

Title column have a value is the first.

If I rename config/packages/stof_doctrine_extensions.yaml stof_doctrine_extension is installed without error.

If I enable config/packages/stof_doctrine_extensions.yaml and run "composer update" I get next error:
There is no extension able to load the configuration for "stof_doctrine_ext
!! ensions" (in "/pendrive/www/symf5/form2/config/packages/stof_doctrine_exten
!! sion.yaml"). Looked for namespace "stof_doctrine_extensions", found ""frame
!! work", "doctrine", "doctrine_migrations", "twig", "twig_extra", "sensio_fra
!! mework_extra", "security", "maker"" in /pendrive/www/symf5/form2/config/pac
!! kages/stof_doctrine_extension.yaml (which is being imported from "/pendrive
!! /www/symf5/form2/src/Kernel.php").

According https://github.com/api-platform/api-platform/issues/1650 there is a conflict, that I try to solve in composer.json putting "gedmo/doctrine-extensions": "^2.3.4 || ^[email protected]",

Thank you friends.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *