NotFoundHttpException after following link in email - laravel

I'm trying to learn Laravel 5.3, so I'm doing my own password reset. In a "reset email" link, I'm sending myself the following link:
http://localhost:8000/users/newpassword/1/8ur7e1pvag6kx8nl0w
In my routes file I have:
Route::get('/users/newpassword/{$id}/{$remember}', 'UserController#newPassword')->name('usernewpassword');
However when I click the link, I'm getting: NotFoundHttpException in RouteCollection.php line 161:
I'm running this via artisan serve, so the port part of the link is correct.
I've also created the following method in the Users controller:
public function newPassword($id, $remember) {
return view('users.newpass');
}
Any ideas why this could be? Thanks!

You mistake in route file. It should be like this
Route::get('/users/newpassword/{id}/{remember}', 'UserController#newPassword')->name('usernewpassword');
Instead of this:
Route::get('/users/newpassword/{$id}/{$remember}', 'UserController#newPassword')->name('usernewpassword');
More about route parameters:
Laravel Route Parameters

Related

Defining routes in api.php and web.php with same name

I have a route in my api.php file
Route::get('category/{id}/subcategory','SubcategoryController#categoryFinder')->name('cat_to_sub.find');
This route worked fine until i added another route in the web.php file
Route::get('category/{id}/subcategory',function(){return view('subcategories');});
And then when i run php artisan route:list
The URI api/category/{id}/subcategory has no name and i referenced that name all over my files and its throwing all these errors saying route cat_to_sub.find not defined
But when i remove the route in the web.php file everything works.
So whats causing this errors and is there another way to do it?

NotFoundHttpException in RouteCollection.php in laravel 5.4

I created a new project via composer create-project laravel/laravel Test 5.4.* then i go to my browser to see my localhost if its working localhost/test/public and it works it redirect me to the welcome page, but when i tried to test
Route::get('/test', function(){
return 'TEST';
});
Then I go to my localhost/test/public/test it shows me error like
NotFoundHttpException: in RouteCollection.php (line 179)
is it a solved issue?
instead of localhost/test/public/test try localhost/test/public/index.php/test.
of course you can use laravel's own server. it is suitable for most developing usages.

Laravel 5.4 php artisan route:list showing incorrect data after a route:clear

I have the following issue. I am running laravel 5.4 and have a problem with my routes, when I navigate to my '/about-me' of my predefined routes I get the error:
1/1 NotFoundHttpException in RouteCollection.php line 179:
However the route is defined as shows here:
Route::get('about-me', function () {
return view('about-me');
});
On my view the link is pointing to that route as shown:
About Me
I have cleared my cached routes in SSH using the command:
php artisan route:clear
When I list my routes using the command:
`php artisan route:list`
I see an old version of my routes file. So this is the problem, however whatever I try they are not updating. I have cleared the cache locally and within laravel and still the old file file is showing when I type the route:list command.
I believe the code is all correct, however the new updated route file which contains the defined route for about-me is not being used. I have attached an image of the updated routes file on the server also.
Here is a link to the screenshot. Screenshot of route file on server
Thanks
In Laravel 5.4 (or in earlier version, I'm not sure) routes has been moved to the separate folder in app/routes/web.php (as you can see here: https://github.com/laravel/laravel).
You can find routes registration in app/Providers/RouteServiceProvider.php (https://github.com/laravel/laravel/blob/master/app/Providers/RouteServiceProvider.php#L52)

Laravel 5.1 NotFoundHttpException in RouteCollection.php line 161

I have an error which you can see in this picture, and I don't know how to fix it. I am using Laravel 5.1.
Error:
Sorry, the page you are looking for could not be found.
NotFoundHttpException in RouteCollection.php line 161
Either make your route something like in your Routes.php file from App\Http folder
Route::get('/laravel/alert/',function(){
//statement here
});
or change your page url to localhost/alert
Hope it will help you.
happyCoding
Assuming you Apache configuration is already pointed to your public folder in your project folder as DocumentRoot, it should able to work by accessing this route:
localhost/alert
I noted you use localhost/laravel/alert which looks wrong because you set your route to be /alert not laravel/alert
If you are not sure this is Apache or Laravel issue, run php artisan serve on the project folder and access the routes with this address, localhost:8000/alert

Call to undefined method Illuminate\Http\Response::view()

I have Laravel installed and now I keep getting this error everytime I run composer update, php artisan routes, or any composer commands:
Call to undefined method Illuminate\Http\Response::view()
I already searched the internet and tried the following suggested solutions so far and nothing worked:
1) A lot of suggested answer on the net says to delete vendor/compiled.php and run the composer update again. But when I went to vendor folder, I cannot find any compiled.php file there. The only file that exists there is: autoload.php
2) I also tried searching for compiled.php inside storage/framework/ folder and nothing there neither.
3) I even tried running optimize with the --force flag php artisan optimize --force and it shows the same error as above.
4) I looked at boostrap/autoload.php for compiled path and it says $compiledPath = __DIR__.'/cache/compiled.php'; I can only see the boostrap/cache folder and that doesnt have this file.
What is wrong here? I am new to Laravel and I dont understand what this error means. Going by the answers out there, I am going around looking for compiled.php to delete and run the update again and I dont even know if that is the right solution for it. Can someone help me here please on how do I proceed troubleshooting this?
I have Laravel 5.1.6 installed after the update I did yesterday. I also ran the composer dumpautoload command today and I wonder if this error started happening after that. Now any commands in composer is giving the above error.
EDIT:
Now even my browser view of the site is showing the error:
FatalErrorException in Facade.php line 210:
Call to undefined method Illuminate\Foundation\Application::missing()
I also tried deleting the complete vendor folder and composer.lock, and re-ran composer install. Towards the end of the installation when generating autoload files, it showed this error again and stopped.
EDIT 2:
#NehalHasnayeen in the comments got it absolutely right. This error was caused due to app calling the view method on Response class, while the response class had no view method. Once I removed that from my route, it worked. This is my route file:
Route::get('/', function () {
return view('index');
//return View::make('index');
});
Route::group(['prefix' => 'api'], function()
{
Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]);
Route::post('authenticate', 'AuthenticateController#authenticate');
});
// -------- THIS WAS CAUSING THE ISSUE - REMOVING THIS WORKED AFTER THAT ------
//App::missing(function($exception) {
// return view('index');
//});
It takes me to my final question, why was the catch-all route throwing this error? I read from here that adding the above will redirect all other route requests to index. What is the right method? Did it change in Laravel 5 or have I done something wrong?
For 1st error:
your app is calling view method on Response class, but response class has no view method, so find the file where it is calling this method & remove it & replace it with correct method
For 2nd error:
App::missing is for laravel 4 version, it is removed in laravel 5. To achieve the same in your app\exceptions\handler.php file add this in render method
public function render($request, Exception $e)
{
if ($e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) {
return response()->view('index', [], 404);
}
return parent::render($request, $e);
}

Resources