one magento developer

my experiences about magento

An exception was raised while creating “Request”; no instance returned in Magento 2

I get error An exception was raised while creating "Request"; no instance returned when I want to use the di compile command, that I test another command and I saw I have the error for all commands.

How we can fix An exception was raised while creating “Request”; no instance returned

I know it’s because of Magento required version of PHP. at the first, we need to check the php cli version. it is too easy, just use the below command

php -v

it should be somethings like this

PHP 7.4.14 (cli) (built: Jan  5 2021 15:11:43) ( NTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

note : the command should be use in bash ,terminal etc.

now we need to know Magento’s PHP version. you can find it in the Magento docs and absolutely this link. or not you can open app/bootstrap.php and at line 17.

Change PHP CLI version in linux

changing PHP CLI version is depend on you OS. i user Linux(Ubuntu).

for change PHPversion use this command

update-alternatives --set php /usr/bin/php7.2

changing php cli version to 7.0

update-alternatives --set php /usr/bin/php7.0

changing PHP CLI version to 7.2

update-alternatives --set php /usr/bin/php7.2

Changing the PHP CLI version to 7.4

update-alternatives --set php /usr/bin/php7.4

update-alternatives: error: alternative /usr/bin/php8 for php not registered; not setting

if you get above error. it is because you does not install PHP version 8

Leave a Reply

Your email address will not be published. Required fields are marked *.

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>