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;
}