Error: Call to undefined method ResourceRegistrar::addResource�ndex()

The Issue

Depending on your server encoding configuration, you will have the error:

Call to undefined method Illuminate\Routing\ResourceRegistrar::addResource�ndex()

or

Call to undefined method Illuminate\Routing\ResourceRegistrar::addResource?ndex()

Explanation

This issue is related to the server encoding, that is not fully encoding in UTF-8. This is a common issue related to Turkish language (or other languages that have not the same value for the uppercase of the character i) with the Laravel framework.

The related lines can be found in the Laravel framework in the file /vendor/laravel/framework/src/Illuminate/Routing/ResourceRegistrar.php:

<?php

namespace Illuminate\Routing;use Illuminate\Support\Str;

class ResourceRegistrar{    
    ...    
    /**     
     * The default actions for a resourceful controller.     
     *     
     * @var array     
     */    
    protected $resourceDefaults = ['index', 'create', 'store', 'show', 'edit', 'update', 'destroy'];    

    ...    

    /**     
     * Route a resource to a controller.     
     *     
     * @param  string  $name     
     * @param  string  $controller     
     * @param  array   $options     
     * @return \Illuminate\Routing\RouteCollection     
     */    
    public function register($name, $controller, array $options = [])    
    {        
        ...        
        foreach ($this->getResourceMethods($defaults, $options) as $m) {            
            $collection->add($this->{'addResource'.ucfirst($m)}(                
                    $name, $base, $controller, $options            
                )
            );        
        }        
        ...    
    }    

    ...
    
}

 

Solution

You have to configure your server resources (Apache, PHP, MySQL) to be encoded only in UFT-8 (or to support only UFT-8 encoding).
Also all edited files must be encoded in UTF-8 without BOM.

Happy fixing!