rvpwebdev's avatar

Maincontroller does not exist while trying to paginate

Hello,

I ran into this weird "bug" today. I developed my website locally, everything works fine over there. Today I pulled the project on my dev server, at first everything seemed okay but when I tried to use my pagination, I ran into this strange RelectionException: "Class App\Http\Controllers\Maincontroller does not exist".

Screenshot of the stacktrace in Whoops: https://gyazo.com/067a6fab8a2391f87cb75b86e37c6dc2

<?php 

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
use App\Page;
use App\Category;
use Session;

use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;

class MainController extends Controller {


    public function __construct()
    {
    }

    public function index()
    {
        return view('home');
    }

    public function search(Request $request){


        $search_results     = array();
        $data['results']    = array();

        if($request->has('search_query')) {
            $search_query       = $request->search_query;
            $alg_results        = Page::search($search_query);

            if(isset($alg_results['hits'])) {
                $search_results     = $alg_results['hits'];
                $request->session()->put('search_results', $search_results);
            }
        }
        else{
            $search_results = $request->session()->get('search_results');
        }

        $paginated = $this->paginate($search_results, 3);
        $paginated->setPath('search/');


        // $data['results']    = $alg_results['hits'];
        $data['results']    = $paginated;


        return view('search_results', $data);

    }

The MainController does in fact exist. /search routes to MainController@search and works fine. The moment i hit the "next page" button (or 2, 3,4 for that matter) laravel throws me this exception.

Things i have tried:

composer clear-cache
composer dump-autoload
php artisan clear compiled
php artisan optimize

chmod -r 777 the whole project (its a dev server anyways)

Removed the whole vendor folder and ran composer install again. Cleared everything after that again.

Nothing seems to help to get it running on my dev server, while on my local machine it is working smooth as ever...

Anyone who ran into something like this, or has suggestions?

0 likes
3 replies
d3xt3r's avatar

Can you show your routes and the links generated by paginator ?

d3xt3r's avatar
d3xt3r
Best Answer
Level 29

What about MainController vs Maincontroller (as seen in screenshot).

Double check your routes for case sensitivity.

Please or to participate in this conversation.