我在一個 Symfony 6.0.9 網站上使用 EasyAdmin 來處理管理面板。我有一個物體 ProfessionalExperience,它的一些屬性是日期。EasyAdmin 的 CRUD 控制器如下所示:
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'),
...
];
}
}
它在我的開發環境中運行良好,并且在 Heroku 上的構建和部署也運行良好。但是當我嘗試點擊訪問已部署網站中管理面板的這一部分時,我在 Heroku 的日志中出現了這個錯誤:
[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
我不明白,因為在我的 Dockerfile 中,我有這個:
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 \
; \
謝謝你幫助我!;)
uj5u.com熱心網友回復:
您可以嘗試在 composer.json 中添加擴展。
您可以在heroku 檔案中看到,您可以通過在 composer.json 中添加可選擴展來安裝它們。
{
"require": {
"ext-intl": "*",
}
}
不要忘記運行composer update并提交您的鎖定檔案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/485148.html
