skip to Main Content

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


  1. Type Error means that Object Manager can’t instantiate given object due to invalid parameters. The class MagentoFrameworkStdlibDateTimeDateTime has a dependency on TimezoneInterface

    public function __construct(TimezoneInterface $localeDate)
    

    Which is implemented by
    MagentoFrameworkStdlibDateTimeTimezone
    which then depends on
    MagentoFrameworkStdlibDateTimeIntlDateFormatterFactory
    that requires PHP-intl extension.
    (in the constructor instantiates IntlDateFormatter)

    $formatter = new IntlDateFormatter(
        $locale,
        $dateStyle,
        $timeStyle,
        $timeZone
    );
    

    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.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. You can check if all module are available/installed in your system by run command in your magento2 root directory:

    composer install
    

    if this give some error then read error there mentioned php-missing modules.

    Then you can install them by :

    sudo apt-get php{php version}-{module name}
    
    example
    sudo apt-get php8.1-intl
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search