Updates to Laravel route file have no effect - php

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.

Related

Laravel project routing is producing errors

I am creating an application to be hosted on a server, and I used .htaccess however the first page that load which is usually the login screen(whose path is in my resources folder)has change to the public folder and I click anywhere else as everything is linking to the public folder, which is not right as its supposed to be in the resources folder... the app works fine, its just the routing that's giving me an issue so when i click anywhere else it says, 'the requested url can not be found on server'
I also tried putting the view folder into the public folder and routing there
my homepage is set to:
Route::get('/', function () {
return view('auth/login');
});
but this gets an error when moved to the public folder, the error reads,
InvalidArgumentException
View [auth.login] not found.
Clear your caches and restart your server:
composer dump-autoload;
//---Flush the application cache
php artisan cache:clear;
//---Remove the configuration cache file
php artisan config:cache;
php artisan config:clear;
//---Remove Routes Cache
php artisan route:clear;

Laravel Keep caching though cleared

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.

Laravel: Routing & Controller

I'm a beginner using this laravel framework. Currently i'm trying to understand the routing and controller of this framework.
I created a controller file using this command:
php artisan make:controller Admin/PostController
Of course the output of this is to create a controller file inside Admin folder. Inside of the PostController.php i wrote a code like this:
public function create()
{
return view('admin.post.post');
}
Also, in my web.php i have this code.
Route::get('/', function () {
return view('user.blog');
});
Route::get('posts',function(){
return view('user.posts');
})->name('posts');
Route::resource('admin/post','Admin\PostController');
The "admin" is a folder and the "post" is a folder too inside the "admin" and when you open the "post" folder you'll see the "post.blade.php" file. The other two route::get in my web.php are working fine. But the route:resource is not working.
When i tried to run this in my browser using this link:
localhost:8000/admin/post/create
The browser says: Sorry, the page you are looking for could not be found
Is there any problem with syntax or path structures?
Here's my post.blade.php
#extends('admin.layouts.app')
#section('main-content')
this is just html codes..
#endsection
Here's my php artisan route:list
this because some time composer stuck, for that times you should stop serve and re generate autoload
1.stop your php artisan serve
2.enter this command
composer dumpautoload
3.run your php artisan serve

Laravel 5.2 Only one specific route not found, but it does exist

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?

Laravel 5 returns blank page for a method which does not exist

I created a RESTful controller with artisan make:controller and i am using resource method at my routes.php, here is my routes.php:
Route::resource('page', 'PageController');
I don't have any edit method at my controller (i removed it) so if i hit this URI:
http://laravel.dev/page/{id}/edit
Laravel should return a 404 page but instance it returns a blank page.
how can i make it return 404 response for a method which does not exist?
Problem was with the permission of storage directory but I'm wondering why it's just happened at this controller? i had no problem with getting errors from other part of the application.
anyway first i changed the permission of the storage directory:
sudo chmod -R 777 storage/
then i got the MethodNotFoundException, so i add the only to the third part of resource method to customize my routes and every thing is fine:
Route::resource('page', 'PageController', ['only' => ['index', 'show'] ]);
now its throw NotFoundHttpException.

Categories