i have problem when install or update composer. When the composer is updated and generated, the autoload file for example autoload_classmap.php changes and no class or file is found. I do not know how to solve. Thanks for the help.
composer.json file
{ "name": "laravel/laravel", "type": "project", "description": "The Laravel Framework.", "keywords": [ "framework", "laravel" ], "license": "MIT", "require": { "php": "^7.3|^8.0", "doctrine/dbal": "^3.1", "fideloper/proxy": "^4.4", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", "larabook/gateway": "^3.4", "laravel/framework": "^8.12", "laravel/tinker": "^2.5", "morilog/jalali": "3.*", "shetabit/payment": "^4.0" }, "require-dev": { "facade/ignition": "^2.5", "fakerphp/faker": "^1.9.1", "laravel/sail": "^0.0.5", "mockery/mockery": "^1.4.2", "nunomaduro/collision": "^5.0", "phpunit/phpunit": "^9.3.3" }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true, "platform-check": false }, "extra": { "laravel": { "dont-discover": [] } }, "autoload": { "files": [ "app/Helpers.php" ], "psr-4": { "App\": "app/", "Database\Factories\": "database/factories/", "Database\Seeders\": "database/seeders/" } }, "autoload-dev": { "psr-4": { "Tests\": "tests/" } }, "minimum-stability": "dev", "prefer-stable": true, "scripts": { "post-autoload-dump": [ "Illuminate\Foundation\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-root-package-install": [ "@php -r "file_exists('.env') || copy('.env.example', '.env');"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ] }
}
and when update composer say: not found class App/ClearingHourTime
class file is :
<?php namespace App; abstract class Enum { static function getKeys() { $class = new ReflectionClass(get_called_class()); return array_keys($class->getConstants()); } } abstract class ClearingHourTime extends Enum { const OPERATION = [ UserType::USR => 0, UserType::ADM => 72, UserType::IND_LAW => 72, ]; }
Advertisement
Answer
I think you have an issue with ClearingHourTime.php, in that file as you are declaring two classes. I think that this practice does not meet psr4 standard, and you are loading app/ under psr4.
To solve this problem you have two options (use only one).
- add “classmap”: [“app/ClearingHourTime”]
"autoload": { "files": [ "app/Helpers.php", ], "classmap": ["app/ClearingHourTime"], .... }
- add “app/ClearingHourTime” to files. like
"autoload": { "files": [ "app/Helpers.php", "app/ClearingHourTime.php" ], .... }
I hope this help