skip to Main Content

My localhost laravel is showing the below error:

TypeError

IlluminateViewFileViewFinder::__construct(): Argument #2 ($paths) must be of type array, null given, called in F:laravelvendorlaravelframeworksrcIlluminateViewViewServiceProvider.php on line 84

PHP 8.1.2
Laravel 10.24.0

Here is F:laravelvendorlaravelframeworksrcIlluminateViewViewServiceProvider.php file LINE 84

/**
 * Register the view finder implementation.
 *
 * @return void
 */
public function registerViewFinder()
{
    $this->app->bind('view.finder', function ($app) {
        return new FileViewFinder($app['files'], $app['config']['view.paths']);
    });
}

I am loading 127.0.0.1:8000 page in localhost.
Yesterday it was loading fine.
I am running php artisan serve.

here is screenshot of the error page

Here is view.php file in config folder

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | View Storage Paths
    |--------------------------------------------------------------------------
    |
    | Most templating systems load templates from disk. Here you may specify
    | an array of paths that should be checked for your views. Of course
    | the usual Laravel view path has already been registered for you.
    |
    */

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

    /*
    |--------------------------------------------------------------------------
    | Compiled View Path
    |--------------------------------------------------------------------------
    |
    | This option determines where all the compiled Blade templates will be
    | stored for your application. Typically, this is within the storage
    | directory. However, as usual, you are free to change this value.
    |
    */

    'compiled' => env(
        'VIEW_COMPILED_PATH',
        realpath(storage_path('framework/views'))
    ),

];

2

Answers


  1. Chosen as BEST ANSWER

    The issue is resolved now as pointed out by Josh Bolton in the answer section here. After I added config/view.php file and issuing

    php artisan config:clear

    The page is loading fine now.


  2. This error is usually caused by a missing or misconfigured view config file. Either edit, or create, a file at config/view.php and the contents should look something similar to the below:

    <?php
    
    return [
    
        /*
        |--------------------------------------------------------------------------
        | View Storage Paths
        |--------------------------------------------------------------------------
        |
        | Most templating systems load templates from disk. Here you may specify
        | an array of paths that should be checked for your views. Of course
        | the usual Laravel view path has already been registered for you.
        |
        */
    
        'paths' => [
            resource_path('views'),
        ],
    
        /*
        |--------------------------------------------------------------------------
        | Compiled View Path
        |--------------------------------------------------------------------------
        |
        | This option determines where all the compiled Blade templates will be
        | stored for your application. Typically, this is within the storage
        | directory. However, as usual, you are free to change this value.
        |
        */
    
        'compiled' => realpath(storage_path('framework/views')),
    
    ];
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search