# Magento 2 - Type Error occurred when creating object: Magento\Framework\Locale\Resolver

Magento 2 requires several PHP Extensions for the project, you can see the requirements here for [Magento 2.4](https://s.id/1Dqsq) and here for [Magento 2.3](https://s.id/1Dqsw).

## How to know more detail?

And by that error, it's bit too general. For more detail about that error, you can try to monitor the logs of your magento by having 2 terminal sessions:

* 1 session to monitor log, and
    
    ```bash
    tail -n 0 -f var/log/*
    ```
    
* 1 session to run the magento command
    
    ```bash
    bin/magento setup:upgrade
    ```
    

## Possible Issues

By that issues, there are several possibility:

### Wrong Crypt Key on env.php

You can try to remove current crypt key on your `app/etc/env.php` file, and try to copy correct key file from existing project.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679546953735/89c088d2-c764-4eb5-b5ac-18c6d0ab9fed.png align="center")

### Lack of PHP mcrypt extension

You can try to check this PHP extension by running `php -info | grep mcrypt`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679547045536/fd7fbc31-58f2-4d2e-9b84-e4b48ddea358.png align="center")

if you dont see that extension, try to install it! in this case I'm using PHP 7.3, so I'm installing mcrypt for php7.3. *If your PHP version is not 7.3, then just change the PHP version to match with your environment.*

```bash
sudo apt install php7.3-mcrypt
```

### Code Error

If those 2 previous issues are not solving your problem, it could be code base issue and you need further investigation, and maybe you can use [*How to know more detail? step*](https://fiko.me/magento-2-type-error-occurred-when-creating-object-magentoframeworklocaleresolver#heading-how-to-know-more-detail) to investigate.

---

References:

* [https://experienceleague.adobe.com/docs/commerce-operations/installation-guide/system-requirements.html](https://s.id/1Dqsq)
    
* [https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements.html](https://s.id/1Dqsw)
    
* [https://github.com/magento/magento2/issues/35464](https://s.id/1DqsC)
    
* [https://magento.stackexchange.com/questions/278222/php-bin-magento-setupupgrade-issue](https://s.id/1DqsL)
    
* [https://gist.github.com/pauloharaujos/bb6173d8f9e64d1b572fe24e55ec109f](https://s.id/1DqsX)
    
* [https://meetanshi.com/blog/solution-type-error-occurred-when-creating-object-in-magento-2/](https://s.id/1Dqt3)
