0

I'm working on a local laravel-nova project which worked fine the last couple of days. Now all of a sudden, when I try to go to the /nova route I get a 404 error saying Page could not be found. I tried with

php artisan config:cache

but without any luck. I even deleted the vendor-folder and ran composer install and php artisan nova:install, but that didn't solve it either.

When I run php artisan route:list I get the error:

Class App\Http\Controllers\Laravel\Nova\Http\Controllers\LoginController does not exist

What happened? How can I solve this?

My Laravel version is 5.7 and I'm running this application on a Windows 10 machine.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ST80
  • 3,565
  • 16
  • 64
  • 124

9 Answers9

8

Add on app/config/app.php

App\Providers\NovaServiceProvider::class,

inside 'providers'.

You may need to run these commands later if that doesn't work:

php artisan nova:publish

And

php artisan view:clear
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ztvmark
  • 1,319
  • 15
  • 11
  • Yes - `php artisan nova:publish` was actually the thing that solved it! Forgot to mention it :-) Thanks anyway - I will accept your answer! – ST80 Mar 26 '20 at 08:20
1

I found it out myself, so just in case other users may have the same problem I'm going to post an answer.

So, if you may have a route like for example:

Route::get('{subpage}', 'SubpagesController@show');

This will return the 404 and you will not be able to access Nova, e.g., the dashboard since Nova (from version 1.0.9) is always registering its routes after the application's routes.

You will have to change the config/nova.php path to either no/va or simply nova by removing the /.

See here for more.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ST80
  • 3,565
  • 16
  • 64
  • 124
1

You might want to try following commands in your terminal:

composer dump-autoload
php artisan clear-compiled
php artisan route:clear
php artisan config:cache
Lonare
  • 3,581
  • 1
  • 41
  • 45
1

This works for me, add the following code in your virtual host:

<Directory /var/www/html/checkin>
    AllowOverride All
</Directory>
Gass
  • 7,536
  • 3
  • 37
  • 41
0

In file LoginController, add use App\Http\Controllers\Controller;.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

Verify that the App\Providers\NovaServiceProvider was added to the providers array in your app\config.php configuration file. If it wasn't, you should add it manually. Of course, if your application does not use the App namespace, you should update the provider class name as needed.

0

I am using Laragon.

In my case, in file config/app.php, add

App\Providers\NovaServiceProvider::class,

I then tried

php artisan nova:publish

But still a 404 error was coming, and then the following

composer dump-autoload
php artisan clear-compiled
php artisan route:clear
php artisan config:cache

It worked fine for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
eak
  • 1
  • 1
0

Try checking the nova routes are listed using the below:

php artisan route:list
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sagiria
  • 1
  • 1
  • Re *"Try checking the nova routes are listed using the below:"*: This is partly incomprehensible. Are you using [machine translation](https://en.wikipedia.org/wiki/Google_Translate)? Can you fix it? – Peter Mortensen Feb 03 '23 at 23:46
0

I battled this for a long time when I was setting up a new laptop and since it was a different answer for me I thought I would share it in case it helps anyone else.

My problem was that I copied the .env file from another computer after cloning the repo.

I spent hours battling this before I discovered that the NOVA_DOMAIN_NAME environmental variable is critical here.

Be sure that variable matches the domain name you are using on the computer that is giving you the 404. I needed the .local TLD and it fixed it, but you will need to use your own of course.

Ted
  • 2,211
  • 2
  • 19
  • 27