0

I am trying to add a new route to my application and can't seem to get it to work. I keep getting a 404 error. It looks like the physical path is looking at the wrong directory. Currently looking at D:\Web\FormMapper\blog\public\forms but should be looking at D:\Web\FormMapper\blog\resources\view\layout\pages\forms.blade.php

My request URL:

http://localhost/FormMapper/           /works fine
http://localhost/FormMapper/forms      /doesn't work
http://localhost/FormMapper/forms.php  /No input file specified.

my FormsController:

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class FormsController extends Controller
{
    public function index()
    {
        return view('layouts.pages.forms');
    }
}

My web.php:

Route::get('/', function () {
    return view('layouts/pages/login');
});
Route::get('/forms', 'FormsController@index');

My folder structure looks like this: enter image description here

My config/view.php

return [
'paths' => [
    resource_path('views'),
],

'compiled' => env(
    'VIEW_COMPILED_PATH',
    realpath(storage_path('framework/views'))
),
];
2
  • Could you add your config/view.php file ? Commented Jan 20, 2020 at 13:35
  • @FouedMOUSSI I just added it. Commented Jan 20, 2020 at 13:41

3 Answers 3

1

you must use dot for this. In your controller change to this:

return view('layouts.pages.forms');
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, same issue. I have also updated the question to see if that was part of the issue.
1

If your route only needs to return a view, you may use the Route::view method. Like the redirect method, this method provides a simple shortcut so that you do not have to define a full route or controller. The view method accepts a URI as its first argument and a view name as its second argument. In addition, you may provide an array of data to pass to the view as an optional third argument:

Route::view('/', 'layouts.pages.login');

Route::view('/forms', 'layouts.pages.forms', ['foo' => 'bar']);

Check docs

1 Comment

This doesn't work either. I am starting to think, something else is the issue.
0

After tracking digging deeper I determined that the issue was that IIS requires URL rewrite rules in place for Laravel to work properly. The index.php and '/' route would work b/c it was the default page but any other pages wouldn't. To test this I used the

php artisan serve

approach to it. and everything worked properly. Unfortunately I am unable to do this in production so I needed to get it to work with IIS.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.