Same error here
Apr 21, 2018
8
Level 2
Error in Eloquent Pagination outside Laravel
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()
{
parent::__construct();
require_once __DIR__.'/../config/database.php';
$db = (object) $db['default'];
$this->addConnection(array(
'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)
$this->setAsGlobal();
// Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
$this->bootEloquent();
}
}
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, [
in
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 or to participate in this conversation.