1

I'm working with Symfony, and the library fzaninotto/faker

I'm using this library to test some stuff, but when running phpunit I have this error:

Error: Class 'Faker\Factory' not found

As usual I'm using the right use Faker\Factory;

As you can see is required only in my dev and I installed it running composer install

composer.json

{
"type": "project",
"license": "proprietary",
"require": {
    "php": "^7.1.3",
    ...
    "symfony/framework-bundle": "4.1.*",
},
"require-dev": {
    "fzaninotto/faker": "^1.8",
    "symfony/dotenv": "4.1.*",
    "symfony/test-pack": "^1.0"
},
"config": {
    "preferred-install": {
        "*": "dist"
    },
    "sort-packages": true
},
"autoload": {
    "psr-4": {
        "App\\": "src/"
    }
},
"autoload-dev": {
    "psr-4": {
        "App\\Tests\\": "tests/"
    }
},
"replace": {
    "paragonie/random_compat": "2.*",
    "symfony/polyfill-ctype": "*",
    "symfony/polyfill-iconv": "*",
    "symfony/polyfill-php71": "*",
    "symfony/polyfill-php70": "*",
    "symfony/polyfill-php56": "*"
},
"scripts": {
    "auto-scripts": {
        "cache:clear": "symfony-cmd",
        "assets:install %PUBLIC_DIR%": "symfony-cmd"
    },
    "post-install-cmd": [
        "@auto-scripts"
    ],
    "post-update-cmd": [
        "@auto-scripts"
    ]
},
"conflict": {
    "symfony/symfony": "*"
},
"extra": {
    "symfony": {
        "allow-contrib": false,
        "require": "4.1.*"
    }
}

}

Francisco Albert
  • 1,577
  • 2
  • 17
  • 34

1 Answers1

0

Possibly my solution is not the best, But instead of the recommended pack "Use Symfony's bridge: composer require --dev phpunit"

I decided to install the usual "composer require --dev phpunit/phpunit ^6.5"

Then everything worked as expected.

Francisco Albert
  • 1,577
  • 2
  • 17
  • 34