Open captainscorch opened 3 years ago
Hmm not as intended indeed.
Can you double check if the STAGEFRONT_ENABLED
setting is true
?
Routes are loaded if it is true
only:
https://github.com/codezero-be/laravel-stagefront/blob/502f5583a5b6119a590865efb0ae59f95db69d38/routes/routes.php#L7
STAGEFRONT_ENABLED=true
was enabled in the .env file.
After removing the routes code from the web.php file again I ran some artisan commands (clear config, clear view, clear cache, etc.). After running php artisan route:cache
I reloaded the website and got redirected to the Stagefront login page. It seems like (now with Laravel 8 maybe?) you have to clear the route cache and renew it in order for the Stagefront routes to work.
Hope that helps you to maybe find a solution for that behaviour or maybe adding this to the documentation in case you can reproduce the same problem.
If I understand correctly, your routes were already cached when you enabled StageFront? In that case it makes sense, because Laravel won't reload the route files, but use the cached ones (as far as I know). When I deploy I always recache routes/config/etc. hence I never encountered this issue.
If you want to enable/disable on runtime (while routes are cached), that means we can't rely on route caching for the StageFront routes. We would need to load the routes another way.
Edit: same goes for the config cache. Which we probably can't bypass...
That's correct. I worked locally with Valet and by default, Routes are cached I think. When deploying with Forge for example, Routes should be recached automatically so it shouldn't be an issue then.
As you said, there is probably no solution for taking care of updating the cache automatically after setting up StageFront without a major change in how routes are working currently.
I guess the easiest solution would be to just add a note or section to the Documentation with the php artisan route:cache
Artisan Command to make sure Routes are recached after the setup.
Feel free to close the Issue, everything is working perfectly fine now!
Hmm, routes shouldn't be cached by default, unless you or your deploy script caches them. But yes, if routes have been cached, you need to recache them when enabling/disabling StageFront.
I will leave this open until I add a note of this to the readme. Thanks for pointing this out. 👍
After successfully installing everything via composer require and setting up the Middleware and updating the .ENV variables with the Quick setup via php artisan. Everything worked fine. After clearing config, view and route cache I reloaded the website but nothing happened. I got a 404 error that the page was not found (/stagefront or /login). I checked the web.php routes file and it didn't have any new configuration or code added. I had to manually add the code from the repo under routes/routes.php to my web.php in order for Stagefront to work properly.
I don't think this is a proper solution nor the indented behaviour as your Readme states Routes should be registered automatically. I'm using Laravel 8.16.1 and "codezero/laravel-stagefront": "^2.3"
If you need any code or other info please let me know.