Laravel 5 - View [home] not found - php

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

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 Custom Controller getting 404 error

I have created the new controller using command line on laravel
php artisan make:controller PhotoController --resource
just display the string on a function of PhotoController like below
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PhotoController extends Controller
{
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function getName()
{
echo 'Dev';
}
Called the controller on route web.php
Route::get('photos', 'PhotoController#getName');
When i trying to load the url of controller
http://localhost/dev_laravel/public/photos
getting 404 Not found error
I also tried
http://localhost/dev_laravel/public/photo/
http://localhost/dev_laravel/public/photo/getname/
I'm beginner or learner for laravel and working on 5.8 version
php artisan route:list
after
Can anyone help me?
Open Terminal
and Run This Command
php artisan serve
Open Second Terminal and run this command
php artisan route:list
And then Your url pattern is like
http://localhost:8000/photos
or
http://127.0.0.1:8000/photos
php artisan serve
it gives a link like http://127.0.0.1:8000/ or your desire port if you set a port for it then just add photos like
http://127.0.0.1:8000/photos

PHP artisan controller error

I try to make a controller with PHP artisan but when I run command php artisan make:controller TasksController I confront with following error:
In RouteAction.php line 84:
Invalid route action: [App\Http\Controllers\TaskController].
why this error to be occur?
Thanks in Advance.
The error occurs because you're trying to execute TaskController without action. You need to add action to the controller:
Route::get('task', 'TaskController#someAction');
If you don't have a similar route, it means routes are cached with some wrong route. Since Artisan commands do not work, clear this cache manually by deleting this file:
bootstrap/cache/routes.php

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.1 View not found

this seems to be an issue that pops up every now and then within Laravel. I was writing a CRUD controller with a view to go with it, however upon testing I got the InvalidArgumentException in FileViewFinder.php line 137: View [bookingcrud.index] not found error. Here is my code:
routes.php:
Route::resource('bookingcrud', 'BookingsCrudController');
BookingsCrudController.php
use uasc\Http\Requests;
use uasc\Http\Requests\CrudCreateRequest;
use uasc\Http\Requests\CrudUpdateRequest;
use uasc\Http\Controllers\Controller;
use Auth;
use DB;
use Illuminate\Pagination\Paginator;
use Illuminate\Http\Request;
class BookingsCrudController extends Controller {
public function index()
{
if (!Auth::check() || Auth::user()->authority < 1) {
return redirect('/login');
}
$raw = "select * from bookings";
$bookings = DB::select($raw);
$paginatedBookings = new Paginator($bookings, 1);
return view('bookingcrud.index')->with('bookings', $paginatedBookings);
}
}
And a view located in ~/laravel/resources/views/bookingcrud/index.blade.php
No matter what is in this view file whether its markup from a working view or just the word "cheese" i will always get:
InvalidArgumentException in FileViewFinder.php line 140:
View [bookingcrud.index] not found.
I tested the same view in a known working controller and got the same error however I tested a known working view on the same CRUD controller and it worked. I have also tried changing the directory of the view and renaming it but i'll get the same error with the "View [bookingcrud.index]" changing appropriately. I made sure the permissions of the file and directories were full for testing.
Since first getting the error I have upgraded to 5.1.1 from 5.0.26 (which is the version the error originated on for me) and ran composer update. Also from looking at threads with the same error I have also ran artisan config:clear
I am developing on Windows 8.1 with Homestead 2.0.17 deployed with Virtual Box.
Any help would much appriciated at this point it is doing my head in.
Please use terminal
homestead ssh > Press Enter
vagrant#homestead cd /Path_of_Your_Project/
vagrant#homestead:~/Path_of_Your_project php artisan cache:clear
vagrant#homestead:~/Path_of_Your_project php artisan config:cache
Sorry about my English
Turns out I had spelt blade incorrectly, took a second pair of eyes to notice it though.
$ ls resources/views/crud/booking/
crud.balde.php index.balde.php
Was definitely a lesson to always double check the small things when debugging.
Thanks for the help.
For someone who don't have SSH Access, There are two ways to solve this problem.
If you don't have any plugin of default Laravel package,
First, Just remove the bootstrap/cache/config.php to solved the file,
OR
If you have any plugin of default Laravel package,
Change all related path mentioned bootstrap/cache/config.php into the exact path which allocated the laravel project.
Remember that Linux is case sensitive!
I had something like this:
return view('MyView', $data);
And it was working on my environment (Mac OS), but not on the deployment server (Ubuntu)!

Categories