DEV Community

Discussion on: php - How to fix "Class '' not found" error

Collapse
 
martial2017 profile image
martial2017

Hello.
thank you for this great job.
I am now faced to this issue of file autoloading. I follow all steps you mentionned and it seems all is correct but there is always the same issue maybe because am new using composer for installing github project like services-openstreetmap from kenguest, and php-osm-tiles-0.1.0.
I really need help to resolve this issue.
thank you

Collapse
 
dechamp profile image
DeChamp

Ok so here are some things you need to check. First you see that it's looking for the PHPUnit class. Which is provided via composer. Now if you look at the composer.json, you'll see PHPUnit is provided via the dev dependencies. How if you do a composer installl --no-dev, the the package would not be available. Another issue, is you need to be running php_osmessa\tests\TileTest.php needs to be ran via phpunit itself. If you try running this by itself, it'll fail. Have you checked your vendor folder for the phpunit files?

Collapse
 
martial2017 profile image
martial2017

ok! thank you for your answer. First I use "composer install" for downloading all dependencies so in phpunit folder located in vendor I have 7 folder named "php-code-coverage", "php-file-iterator", php-test-template", "php-timer","php-token-stream", "phpunit", "phpunit-mock-objects".
I think all files is there.
the purpose of my work is to use these classes for loading map tiles from php application so need to run it from browser.
But when I run it by php line command php php_osmessa/tests/Tiletest.php

Thread Thread
 
dechamp profile image
DeChamp

So that is what I was saying. Those are actual “test” plans. Not a “try out your functionality”. You should read up on phpunit. Don’t run those files under the test folder with ‘php ...’ but instead run them with ‘phpunit ...’

Collapse
 
dechamp profile image
DeChamp

Sure I'm happy to help you. What error are you getting now?

Collapse
 
martial2017 profile image
martial2017

OK! thank you!
when I unzip the project php-osm-tiles for example downloaded from github execute composer line command for requires and just want to test with webbrowser I get these issue
" Fatal error: Class 'PHPUnit\Framework\TestCase' not found in C:\wamp\www\php_osmessa\tests\TileTest.php on line 9
"
but the class exist and there is a autoload file all that download from github project.

Thread Thread
 
dechamp profile image
DeChamp

I'm super sorry for the delay, I will look at this tonight!