JackJones's avatar

Laravel can't find class that is definitely there

I have my Service Provider

<?php

namespace App\Providers;

use App\Services\Extractors\OrdnanceSurveyExtractorService;

class ExtractorServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        dd(new OrdnanceSurveyExtractorService);

I have my class

<?php

namespace App\Services\Extractors;

class OrdnanceSurveyExtractorService
{

}

It's empty just for testing

It is definitely in the right folder because all of the other classes are working fine

I just can't get my head around why it won't find this particular class

When I press F5 it imports it fine, so it is definitely there

0 likes
3 replies
JackJones's avatar

Nevermind, I restarted php artisan serve and it's working now, I have no idea what that was all about and why a restart would make it work

RobFrancken's avatar

@JACKJONES - Sometimes new classes don't get added to the autoloader (usually happens to me if I copy a class rather than generate one with artisan command). Not sure if that's what happened, but you can always do a composer dump-autoload for vendor/autoload.php to be updated.

2 likes
munazzil's avatar

You just used as like below and check it added(//)?

<?php

namespace App\Services\Extractors;

class OrdnanceSurveyExtractorService
{
         //
}

Please or to participate in this conversation.