Home > Net >  Error with date/time fields in EasyAdmin once deployed on Heroku
Error with date/time fields in EasyAdmin once deployed on Heroku

Time:06-02

I work on a Symfony 6.0.9 website with EasyAdmin to handle the administration panel. I've got an entity ProfessionalExperience with some of its properties that are dates. Its CRUD controller for EasyAdmin looks like this :

class ProfessionalExperienceCrudController extends AbstractCrudController
{
    public static function getEntityFqcn(): string
    {
        return ProfessionalExperience::class;
    }

    public function configureCrud(Crud $crud): Crud
    {
        ...
    }

    public function configureFields(string $pageName): iterable
    {
        return [
            ...
            DateTimeField::new('start')
                ->setFormat('Y-MM-dd'),
            DateTimeField::new('stop')
                ->setFormat('Y-MM-dd'),
            ...
        ];
    }
}

It works just fine in my dev env and the build and deploy on Heroku works fine too. But when I try to click to access this part of the administration panel in the deployed website, I've got this error in Heroku's logs :

[critical] Uncaught PHP Exception LogicException: "When using date/time fields in EasyAdmin backends, you must install and enable the PHP Intl extension, which is used to format date/time values." at /app/vendor/easycorp/easyadmin-bundle/src/Field/Configurator/DateTimeConfigurator.php line 37

I don't understand, because in my Dockerfile, I've got this :

RUN set -eux; \
    apk add --no-cache --virtual .build-deps \
        $PHPIZE_DEPS \
        icu-dev \
        libzip-dev \
        zlib-dev \
    ; \
    \
    docker-php-ext-configure zip; \
    docker-php-ext-install -j$(nproc) \
        intl \
        zip \
    ; \

Thanks for helping me ! ;)

CodePudding user response:

You could try adding the extension in your composer.json.

You can see in the heroku documentation that you can add optionnal extension to install by adding them in your composer.json.

{
    "require": {
        "ext-intl": "*",
    }
}

Don't forget to run composer update and commit your lock file.

  • Related