I have an annoying problem on Laravel, Though I clear all cached it's still caching. I've try to rename routes as like :
Route::get('/damn', function () {
dd(1);
});
it's should show me 1 but I when I try to check on browser the web still show me the normal view.
I was try with
php artisan config:cache
php artisan route:cache
php artisan cache:clear
and It's keep caching till I run
php artisan optimize
when I edited the route again , It's caching again and again and always must to run artisan optimize
Anyone can help me out ?
You can simply place the below code in your routes/web.php file of Laravel application. Then access this URL in the browser to clear the cache of Laravel application.
Route::get('/clear-cache', function() {
Artisan::call('cache:clear');
return "Cache is cleared";
});
Maybe have another route with the same uri and it returns a view.
Related
I have deployed my Laravel 8 application on live server and have set up the reverse proxy successfully to access the laravel app from a url like example.com/app/my-app.
Now the problem is, as I have used auth middleware which requests user to log in before he/she can access the app, opening example.com/app/my-app redirects to localhost:8000/login
Which is wrong as it is supposed to redirect to example.com/app/my-app/login
I have:
set the 'url' => "example.com/app/my-app" in config/app.php
ran php artisan optimize:clear
ran php artisan cache:clear
And also stopped the app and ran php artisan serve again
Can you please help me? Am I missing something?
You can use in web.php, if user not auth redirect '/' => '/login'
Route::group(['middleware' => 'guest'], function () {
// Redirect '/' => '/login'
Route::redirect('/', '/login');
// Auth routes
Auth::routes();
});
Remove the file inside the bootstrap/cache directory.Then run the following command :
php artisan cache: clear
php artisan config: clear
php artisan view: clear
php artisan route: clear
php artisan config: cache
php artisan optimize
Hope this will fixed your problems.
I am trying to create a view to display data from the database but I discovered that my route file doesn't do anything anymore.
At the moment I am trying to get the test function working but when I go to /test it just says "Page not found". The other routes work. Even if I delete all of the contents and save the file, all the other routes work.
I have tried artisan route:clear, artisan cache:clear and so on but nothing works.
This is my route file.
Route::get('/test', function () {
return "ok";
});//this is not workig
Route::get( '/', function () {
return view( 'welcome' );
} );
Route::resource( 'submission', 'SubmissionController' );
When you execute php artisan route:cache, Laravel creates a cached routes file in the bootstrap/cache/routes.php directory. While this file exists all your other apps route files will be ignored.
Anytime you create new routes you will need to re-generate the routes cache by executing php artisan route:cache.
If you need to remove the route cache you can execute php artisan route:clear.
If the above fails to solve your problem, it could indicate a permissions problem. Make sure the bootstrap/cache directory has the correct permissions to be altered/deleted.
Failing that, you could manually delete the bootstrap/cache/routes.php file yourself.
I Blog in Laravel v5.6
when translate new route it doesn't work for me
but old route like login and register and landing pages it working as well when i going in new route it's not
Switch Lang page
Route::get('locale/{locale}', function ($locale) {
Session::put('locale', $locale);
return redirect()->back();
// this link will add session of language when they click to change langauge
})->name('locale');
Route::get('/{username}', 'ProfileAccountController#index')->name('profile')->middleware('admin.user');
when i going to this route it's not working and navbar and footer it's back to key, remove all code in this page and test the lang it's not work too.
I use all of this command and nothing
php artisan config:cache
php artisan config:clear
php artisan cache:clear
php artisan view:clear
php artisan clear-compiled
Thank you.
My suggestions:
Use middle-wear for changing languages and use https://github.com/spatie/laravel-translatable like this for more comfortable usage.
Also check this Change language in Laravel 5 might help you.
Had similar issues with Route closures. Try moving you're session setters/getters to a Controller and not within a Route closure.
https://laravel.com/docs/5.7/session#using-the-session
This will probably solve your issues.
I have been encountering a weird problem with Laravel over the last week.
Basically, lets say for example that I am editing a view, "view.blade.php", and the controller, "ViewController.php", and I am constantly refreshing the browser page to see my changes.
My view is loaded by the index() function of my ViewController like so:
public function index()
{
return view('view');
}
Everything is working and I am seeing my changes reflected in the browser. However, all of a sudden for some reason, the page goes white and my view stops loading. No error in Laravel.log or console, nothing. It just shows a white page.
The thing is, if I change the name of my view file to "view2.blade.php" and change my index function to return 'view2' instead, the page loads as normal and works perfectly. It seems that the file name is the only thing keeping the page from loading.
I have tried clearing all the caches with the following artisan commands:
php artisan route:cache
php artisan cache:clear
php artisan view:clear
php artisan config:cache
and executing php artisan optimize
However, the problem still persists. I have not modified or added any vendor files.
This doesn't happen too often but it is annoying and it normally "magically" solves itself when I leave it alone for a while to work on another view/controller. However, I just want to know if anyone else has this problem and if there is a solution anywhere.
I defined my route like so:
Route::resource('view', 'ViewController');
Using Laravel 5.4
try to clear browser cash ctrl + F5
Hey try this url http://yoursite.dev/view/, do note you need to replace the yoursite.dev with your local domain.
By including the 'view' string in the resource function you are making a restful resource relative to the /view base domain.
Here is a link to the docs https://laravel.com/docs/5.4/controllers#resource-controllers
reference the table Actions Handled By Resource Controller for a thorough explanation.
No matter what I try, the route /authenticate/{code} returns a NotFoundHttpException.
My route in routes.php:
Route::get('/authenticate/{code}', ['as' => 'authenticate', 'uses' => 'FrontendController#getAuthenticate']);
When I am calling the route:
URL::route('authenticate', $code)
On my local machine it runs it just fine, but on my production server, it takes me to a NotFoundHttpException page.
It does site inside of the web middleware group.
I have tried (with no success):
resetting the github repo on the server (fresh install)
composer update
php artisan cache:clear
php artisan view:clear
php artisan route:clear
php artisan config:clear
composer dump-autoload
changing the route from authenticate to authenticate-email
What could it be? Every other route on the site works, it is just this one that doesnt.
The only thing I can think to advise is switching from using the URL Facade to using the built in helper function $url = route('authenticate', ['code' => $code]); I only say this because I can't seem to find in the docs how you hint at URI parameters when using URL::route() :)
I also ran into this issue. I deleted the route, then copy another working route and changed the route name and parameters with the one. And It Worked
I don't know if you solved this but I just had exactly the same problem, nothing I did would make the route work. It was a really simple route: Route::get('/search', ['middleware' => 'shop_session','uses' => 'Cinder\StoreController#viewProducts']);
Did all the things you did. In the end I moved the route to the top of my routes file, ran php artisan route:cache and it worked.
Not a great answer and I've got no idea why it worked but it did. Maybe worth a try?