phpunit no phpstorm

Asked

Viewed 77 times

2

I’ll run unit tests for phpunit in my stage and I can’t put it in the project. I added the file composer.json and when I will try to add dependency phpunit/phpunit, it presents the following error:

composer require phpunit/phpunit:8.0.4 -n --no-progress --no-interaction
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for phpunit/phpunit 8.0.4 -> satisfiable by phpunit/phpunit[8.0.4].
- phpunit/phpunit 8.0.4 requires php ^7.2 -> your PHP version (7.0.33) does not satisfy that requirement.

Installation failed, reverting ./composer.json to its original content.

1 answer

1


When I see your code, I see that your machine does not have the mbstring extension.

phpunit/phpunit 8.0.4 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.

You must install this extension (or activate it) before trying to install Phpunit.

Solution 1 - Activating the extension:

Look for the php.ini configuration file on your machine. To find where it is, type the command in the terminal php -i.

Search in the first lines a line started like this: Configuration File (php.ini) Path. What comes next indicates the folder where your configuration file is.

Locate this folder and open the file php.ini. Then add the following line:

(If you are on Windows)

extension=php_mbstring.dll

(If you are on Linux)

extension=php_mbstring.so

Run the installation command again. If you are giving error, let’s go to the 2nd solution:

Solution 2 - Activating mbstring

In Ubuntu you must execute the following command:

sudo apt install php-mbstring

I think with that, you should solve your problem.

I hope I’ve helped.

P.S.: Please inform your operating system and which server you are using, editing the question, so we can offer the best answer for you.

Issue #1 to reflect changes to the question

The mistake: Problem 1 - Installation request for phpunit/phpunit 8.0.4 -> satisfiable by phpunit/phpunit[8.0.4]. - phpunit/phpunit 8.0.4 requires php ^7.2 -> your PHP version (7.0.33) does not satisfy that requirement. indicates that the PHP version is not supported by the latest version of Phpunit.

You can solve it in two ways:

  • Installing an old version of Phpunit or,
  • Installing a newer version of PHP.

I hope I’ve helped.

  • I executed the command to install php-mbstring. With this, a new error came up. I edited my question with this new error. Thanks for the help!

  • Dear. The mistake Installation request for phpunit/phpunit 8.0.4 -> satisfiable by phpunit/phpunit[8.0.4]. - phpunit/phpunit 8.0.4 requires php ^7.2 says that Phpunit only works with versions of PHP above 7.2. You have to update the PHP version. If you’re using Windows, just look for a server that supports PHP 7.3. If you are using Linux look in your package manager. If you cannot find it, update your Linux system.

  • A hint. Try to keep what you wrote before. Put the new error below what you wrote in your question, indicating that it is an edit. So we keep the conversation going.

  • Got it. I will try to install an older version of phpunit. Thanks again!

  • Ok. If the answer leads to the solution of the problem, try to mark it as the accepted answer by clicking on the green tick. So other people will know to find the right one. I thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.