0

Why PHP / laravel informs me a "class not found" error even passing the complete namespace in the assignment of values ​​in the constants?

I'm running a background process using php artisan, and there is a specific class that assigns a constant to a constant of another generic class.

FILE_1: 

namespace App\Elasticsearch;
class Errors
{
   const UPDATE_DOCUMENT = 'xxx';
}

FILE_2:

namespace App\Services\Exceptions;
class UpdateDocumentException 
{
  const ERROR = \App\Elasticsearch\Errors::UPDATE_DOCUMENT;
}

When I execute the command like this, it displays the message : Class 'App\Elasticsearch\Errors' not found

When I put use of class Errors below the declaration of namespace in FILE_2, it works correctly, the difference below follows:

FILE_2:

namespace App\Services\Exceptions;
use App\Elasticsearch\Errors;

class UpdateDocumentException extends DocumentException 
{
  const ERROR = Errors::UPDATE_DOCUMENT;
}
tereško
  • 58,060
  • 25
  • 98
  • 150
José Victor
  • 125
  • 10

1 Answers1

1

I solved this problem by running the command : composer dump-autoload

José Victor
  • 125
  • 10