I'm creating a tool with laravel nova.
I ran this command first,
php artisan nova:tool mytools/cachier
And then in my mai app directory App\Providers\NovaServiceProvider I added,
use Mytools\Cachier\Cachier;
public function tools()
{
return [
new Cachier(),
];
}
This is my tool composer json
{
"name": "mytools/cachier",
"description": "A Laravel Nova tool.",
"keywords": [
"laravel",
"nova"
],
"license": "MIT",
"require": {
"php": ">=7.1.0"
},
"autoload": {
"psr-4": {
"Mytools\\Cachier\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Mytools\\Cachier\\ToolServiceProvider"
]
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
But now when I'm trying to access app I'm getting this error.
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'Mytools\Cachier\Cachier' not found
It would be great if someone can help :'(
Check the namespace
that you imported:
use Mytools\Cachier\Cachier; // <----
public function tools()
{
return [
new Cachier(),
];
}
I think it should be:
use Mytools\Cachier; // <----
// ...
PS: Also, check the namespace
defined inside your class to match this one.
For anyone googling this--or OP if you haven't figured it out yet--I had this issue because I didn't run the composer or npm commands while generating the tool. Try composer update mytools/cachier
from the project root.