I am trying to use ReflectionClass to get file name from a controller. For testing whether I can use the ReflectionClass or not i was trying in following way:
In my MyController.php
public function readContent()
{
$files = app_path() . DIRECTORY_SEPARATOR. "Drama.php";
// It returns "F:\xampp\htdocs\projectDirectory\app\Drama.php"
$class = new ReflectionClass($files);
echo "file name:: ". $class->getFileName();
}
I have a Drama.php
file in this path. But when I am running the route for this method, I get following error
ReflectionException (-1)
Class F:\xampp\htdocs\projectDirectory\app\Drama.php does not exist
I have updated my composer.json
file like following:
"autoload": {
"classmap": [
"app",
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
So that, i can read my app
directory files.
I also ran the following commands
- composer dump-autoload
- composer update
- php artisan config:clear
- php artisan cache:clear
But i am still getting this error. Can anyone tell me how can i resolve this ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire