NotFoundHttpException in RouteCollection.php when after sync with github desktop - php

My laravel project is showing this error: NotFoundHttpException in RouteCollection.php when i am trying to sync my project to github using github desktop, except for this route:
Route::get('/', function () {
return view('welcome');
});
but another simple route like following will not work, and return that error.
Route::get('loa', function () {
return view('loa');
});
In route list, using route command: php artisan route:list it says it exists. but it always returns Route not found. I also have tried to use the command dump-auto load or route:clear, but nothing is working.

Run composer update then try again.

Related

Laravel (ver 6) php artisan route:list return "Target class does not exist" error with production environment (worked fine in local environment)

I'm using laravel 6 for BE and vuejs for FE. Wtih my local environment ( built on xampp server ), everything was fine. But, when I deployed the app to the server(Lamp server with ubuntu 18.04), I got the following error when I tried to run "php artisan route:list".
Illuminate\Contracts\Container\BindingResolutionException : Target class [App\Http\Controllers\Masterdata\CountryController] does not exist.
at /var/www/html/performance.goautobot.chat/public_html/performance/vendor/laravel/framework/src/Illuminate/Container/Container.php:806
try {
$reflector = new ReflectionClass($concrete);
} catch (ReflectionException $e) {
throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
}
And some APIs are not working. The weird part is both "Roles" and "Countries" have exactly the same structure as the following but only apis related to "Roles" are working got "BindingResolutionException" error when I tried with Postman.
Route::group(['middleware' => 'auth:api'], function () {
// Countries
Route::get('masterdata/countries', 'Masterdata\CountryController#index');
// Roles
Route::get('masterdata/roles', 'Masterdata\RoleController#index');
}
I tried to solve it by running the commands like "composer dump-autoload" and "php artisan config:cache" but it didn't fix the problem. Also, tried to remove the project folder and made a new installation and deployment.
Please let me know how to fix the issue. Thank you so much in advance.
I had a similar issue with HomeController, then I checked the routes in the web.php file,
I found it was like the following
Route::get('/', 'HomeController#index');
Then I changed this to the following according to the directory where the Homecontoller resides
Route::get('/', 'App\Http\Controllers\HomeController#index');
after that, it worked correctly.
So Please check your controller directory,
if your controller directory is "App\Http\Controllers\Masterdata\CountryController" then add this in the route. it will be like following
Route::get('/', 'App\Http\Controllers\Masterdata\CountryController');
I tried to explain according to my scenario,
Please let me know if this helps and please pardon me if I have got something wrong

Laravel 5.2 bind controllers to abstract route

I am upgrading application written in Laravel 4.2 to Laravel 5.2.
I have long namespaces for my controllers and want to shorten them.
For example:
CustomServiceProvider.php
public function register()
{
$this->app->bind('Shortname\Somecontroller', 'Really\Really\Long\Name\Somecontroller');
}
routes.php
$router->get('someroute', ['uses' => 'Shortname\Somecontroller#someFunction']);
was possible inside custom service provider and works in Laravel 4.2 and Larave 5.1. After I've started migrating to Laravel 5.2 it stopped working.
Closest I came to the solution was this issue report: https://github.com/laravel/framework/issues/14920 but it doesn't work either.
This works for example:
routes_alternative.php
$router->get('someroute', ['uses' => 'Really\Really\Long\Name\Somecontroller#someFunction']);
I've tried Really\Really\Long\Name\Somecontroller::class and moving everything to RouteServiceProvider. I've also tried artisan route:clear,artisan cache:clear, artisan dump-autoload, artisan clear-compiled and all sorts of other composer and artisan shenanigans.
All actions result in exception:
ReflectionException in Route.php line 280:
Class Shortname\Somecontroller does not exist
Does someone have similar expiriences and was able to solve it?

Laravel 5 doesn't route to page in view, when added in routes.php

I 'm new to LARAVEL 5 ,so i have created about.blade.php in ~/project/resources/views and then add this code in app/routes.php in order to view the page when requested in browser:
Route::get('about', function () {
return view('about');
});
========================================================================
Then i requested in browser as this : http://localhost:8000/about .
so this error is shown in browser :
[
I solved this issue using sudo command with php artisan serve
It was Permission issue .

I am getting NotFoundHttpException in RouteCollection.php line 161:

I am getting this error when I run it at http://localhost/myproject/public/vendor
the following is my routes:
Route::get('vendor', array('as'=>'vendorform','uses' => 'VendorController#create'));
Route::post('vendor', array('as'=>'saveVendor','uses' => 'VendorController#store'));
This is my create method in VendorController
public function create()
{
//
return view('vendor');
}
When I run php artisan route:list the route vendor is not listed
I have tried route:clear in the php artisan but this could not solve the problem.
vendor.blade.php is under /resources/views directory
Please any help. What's challenging me is that some routes configured in the same way works while others cannot work.
Please help.
You should not use public in url you run. You should run http://localhost/myproject/vendor url

Laravel 5 - View [home] not found

I ran composer update and now I'm running into an issue. I'm getting this error when I'm trying to load my home view:
InvalidArgumentException in FileViewFinder.php line 140:
View [home] not found.
Yes, files exists in my directory (resources/views, etc.). Name is home.blade.php.
My controller:
<?php namespace Hulahoop\Http\Controllers;
use Hulahoop\Http\Requests;
use Hulahoop\Http\Controllers\Controller;
use Illuminate\Http\Request;
class HomeController extends Controller {
/**
* Display a listing of the resource.
*
* #return Response
*/
public function index()
{
return view('home');
}
}
Route:
Route::get('/', 'HomeController#index');
This was working fine and it's very basic function. What happened? Running on local homestead FYI.
UPDATE: When I run php artisan serve, I can view the home page view fine (i.e. on http://localhost:8000). But on homestead, no dice. What gives?
There seem to be a problem with vagrant and php artisan config:cache.
If you run php artisan config:clear and then try to open the page - you should see it working fine - just make sure you don't cache it via artisan.
Check out [ vendor/config.php ] it's hard-coded for local development.
You need to give executable permission for the view folder 755

Categories