I created a vendor library with this configuration:
"autoload": {
"psr-4": { "Company\\PhpUtils\\": "src/" }
},
Directory structure:
php-utils/
---src/
------JSON/
--------Json.php
Json Class:
<?php
namespace Company\PhpUtils\JSON;
Now I include it as a dependency:
"company/php-utils": "1.0.0"
and use it in a symfony test:
<?php
namespace Tests\AppBundle\Controller;
use Company\PhpUtils\JSON\Json;
Run tests:
./vendor/phpunit/phpunit/phpunit ./tests
PHPUnit 4.8.22 by Sebastian Bergmann and contributors.
PHP Fatal error: Class 'Company\PhpUtils\JSON\Json' not found in...
The class Json is static... well... follows singleton pattern.
So...Easy question. What am I doing wrong?
In your phpunit command there's no bootstrap, change from:
./vendor/phpunit/phpunit/phpunit ./tests
To:
./vendor/phpunit/phpunit/phpunit ./tests --bootstrap ./vendor/autoload.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.