Error in Eloquent Pagination outside Laravel

Posted 1 year ago by ehsanquddusi

I am using Illuminate/database package outside Laravel with my CodeIgniter setup. The initialization is done using Capsule class like this

use Illuminate\Database\Capsule\Manager as CapsuleManager;
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;

class Capsule extends CapsuleManager
public function __construct()

    require_once __DIR__.'/../config/database.php';
    $db = (object) $db['default'];

        'driver'    => 'mysql',
        'host'      => $db->hostname,
        'database'  => $db->database,
        'username'  => $db->username,
        'password'  => $db->password,
        'charset'   => $db->char_set,
        'collation' => $db->dbcollat,
        'prefix'    => $db->dbprefix,

    $this->setEventDispatcher(new Dispatcher(new Container));

    // Make this Capsule instance available globally via static methods... (optional)

    // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())

I had it running on illuminate/database 5.2. Recently I updated it to illuminate/database 5.5. My Eloquent paginate() has stopped working. The links() method on eloquent collection gives following error.

    Call to a member function make() on null

With a stack trace to

    return new HtmlString(static::viewFactory()->make($view ?: static::$defaultView, array_merge($data, [


     vendor\illuminate\pagination\LengthAwarePaginator.php on Line 90

The issue lies with viewFactoryResolver() as it can't resolve the view class.

I am using following code to initialize the paginator class.

Paginator::currentPathResolver(function() use ($path) { 
    return site_url($path);
$page = Input::get('page');
Paginator::currentPageResolver(function() use($page) { 
    return $page;

My composer.json file has following dependencies for eloquent.

"illuminate/database": "5.5",
"illuminate/events": "5.5",
"illuminate/pagination": "5.5",
"doctrine/dbal": "~2.6",

Any help in this regard will be appreciated.

Please sign in or create an account to participate in this conversation.