I’m having a problem when I install new Magento 2 on my ubuntu. I got an error when I run the command:
sudo bin/magento setup:install
--admin-firstname="zzz"
--admin-lastname="zzz"
--admin-email="[email protected]"
--admin-user="admin"
--admin-password="admin123"
--db-name="zzzdb"
--db-user="root"
--db-password=""
Error:
Type Error occurred when creating object: MagentoFrameworkStdlibDateTimeDateTime
I’ve consulted the solutions but it seems to be creating a new project, not installing. And I tried rm -rf generated/
, chmod -R 777 generated/
. But it doesn’t work =((
Thanks for any answers.
3
Answers
Type Error means that Object Manager can’t instantiate given object due to invalid parameters. The class MagentoFrameworkStdlibDateTimeDateTime has a dependency on TimezoneInterface
Which is implemented by
MagentoFrameworkStdlibDateTimeTimezone
which then depends on
MagentoFrameworkStdlibDateTimeIntlDateFormatterFactory
that requires PHP-intl extension.
(in the constructor instantiates IntlDateFormatter)
My guess is that you haven’t installed intl extension for PHP.
https://www.php.net/manual/en/intl.installation.php
You can get more verbose input by providing -vvv as the command argument.
That is very simple, since DateTime object always contains a timezone, it is possible to translate it into UTC at any time. As you see, it does call internally MagentoFrameworkStdlibDateTime to convert time into a text representation.
Ideally, as with any other modern PHP ORM, you should be able to specify the DateTime object, and the rest of how it is stored should be processed by the library itself. So, it’s very well known that during installation, the PHP intl extension is missing.
Hope it will help you.
You can check if all module are available/installed in your system by run command in your magento2 root directory:
if this give some error then read error there mentioned php-missing modules.
Then you can install them by :