Module route "uses" throwing error on install
Created 6 years ago by emergingdzns

Did something change recently in the module service provider methodology? I am trying to install a new module on a new installation of Pyro and I'm getting this error:

ErrorException (E_NOTICE)
Undefined index: uses

In the pretty page output on the right it's highlighting the following lines of vendor/anomaly/streams-platform/src/Addon/AddonProvider.php (338&339):

            if (is_string($route['uses']) && !str_contains($route['uses'], '@')) {
                $this->router->resource($uri, $route['uses']);

Here's an example of my $routes variable in my new module:

    protected $routes = [
        'admin/horses/registrations'           => 'Evet\HorsesModule\Http\Controller\Admin\RegistrationsController@index',
        'admin/horses/registrations/edit/{id}' => 'Evet\HorsesModule\Http\Controller\Admin\RegistrationsController@edit',
        'admin/horses/payments'           => 'Evet\HorsesModule\Http\Controller\Admin\PaymentsController@index',
        'admin/horses/payments/edit/{id}' => 'Evet\HorsesModule\Http\Controller\Admin\PaymentsController@edit',
        'admin/horses'           => 'Evet\HorsesModule\Http\Controller\Admin\HorsesController@index',
        'admin/horses/create'    => 'Evet\HorsesModule\Http\Controller\Admin\HorsesController@create',
        'admin/horses/edit/{id}' => 'Evet\HorsesModule\Http\Controller\Admin\HorsesController@edit',

        'horses'                => ['middleware' => 'auth',
                                    'uses' => 'Evet\HorsesModule\Http\Controller\HorsesController@index'],
        'horses/create'         => ['middleware' => 'auth',
                                    'Evet\HorsesModule\Http\Controller\HorsesController@create'],
        'horses/remove/{id}'    => ['middleware' => 'auth',
                                    'Evet\HorsesModule\Http\Controller\HorsesController@remove'],

        'cart'                  => ['middleware' => 'auth',
                                    'Evet\HorsesModule\Http\Controller\RegistrationController@cart'],
        'cart/add/{horseId}'    => ['middleware' => 'auth',
                                    'Evet\HorsesModule\Http\Controller\RegistrationController@addToCart'],
        'cart/remove/{id}'      => ['middleware' => 'auth',
                                    'Evet\HorsesModule\Http\Controller\RegistrationController@removeFromCart'],
        'cart/update'           => ['middleware' => 'auth',
                                    'Evet\HorsesModule\Http\Controller\RegistrationController@updateCart'],

        'checkout'              => ['middleware' => 'auth',
                                    'Evet\HorsesModule\Http\Controller\RegistrationController@checkout'],
        'checkout/receipt'      => ['middleware' => 'auth',
                                    'Evet\HorsesModule\Http\Controller\RegistrationController@checkoutComplete'],
    ];

I've already syntax checked my code and it's fine. I've used this same ["uses" => 'xxx@yyy', 'middleware' => 'auth'] scheme in previous modules with perfect success. Now the module is installed but breaking the entire site and artisan with it so I can even uninstall the module. What do I do now?

emergingdzns  —  6 years ago Best Answer

Nevermind. Somehow I only got 'uses' => before the first route. Ugh. That's what I get for coding tired.

ryanthompson  —  6 years ago

Ok we good here? Let me know if you run into anything that needs fixed I'll take care of it 😊