Anyone? This pagination seems to be very handy, but I simply can not find out how to use it!
Still getting to know the framework, so i'm not sure of how Paginate interacts with the Capsule class. But my first suspicions are these:
At the top of the class do you have a use Illuminate\Paginate statement?
Also check your Service Providers array in /app/config/app.php for the \Paginate class.
What I should mention is, I'm using laravel classes OUTSIDE a laravel install (in Concrete5 CMS actually). I've used the composer config below:
{ "require": { "illuminate/database": "", "doctrine/dbal": "", "illuminate/http": "", "illuminate/pagination": "" } }
So I got the pagination, but for some reason it can't find the paginator class. Now I need to have some use statement perhaps, like Marnu mentions, but I have no idea what exactly.
To give an example, I can use the DB class as followed:
use Illuminate\Database\Capsule\Manager as Capsule; $db = new Capsule;
Every function goes to $db, i.e. $db->table('tablename')->where('column', '=', 'test');
Now upon doing paginate on this, I'm getting the error "Class paginator does not exist".
Hope this explains it a little more. I'm not including the whole laravel app folder, just some standalone packages using composer!
So in other words, I'm trying to achieve this WITHOUT using the whole laravel install/packages. I've just grabbed the ones stated above in the composer config file. I need to load the class or something, but I simply don't know which ones, as there are more dependencies from what I can see.
Hope someone can help me out with this matter :)
I recall a major complaint about the paginator being that it's unusually tightly-coupled to the rest of the framework. Unfortunately I can't offer you any advice on the subject, but if you look at the PaginationFactory and PaginationServiceProvider classes here, it should at least give you a place to start: https://github.com/illuminate/pagination
like @thepsion5 pointed out, the pagination module is tightly-coupled.
To get an instance of a paginator class, you have to satisfy the following object graph.
Paginator's constructor requires an instance of 'Environment' class
Environment
Request
ViewEnvironment
EngineResolver
ViewFinderInnterface
Dispatcher
Container
TransaltorInterface
After implementing/adding all of the dependencies, you then have to bind 'paginator' like
$capsule->getContainer()->bind('paginator', 'Illuminate\Pagination\Paginator');
so I guess..it would take at least a few hours to make it work.
OK, I binded the paginator with the code you suggested @moon0326
Now I get the following:
Target [Illuminate\View\ViewFinderInterface] is not instantiable.
I do have the view package though (so ViewFinderInterface.php is located in illuminate/view/Illuminate/View/).
I though perhaps binding like this, ->bind('ViewFinderInterface', 'Illuminate\View\ViewFinderInterface');, would help, but that didn't obviously. I simply haven't got the knowledge to get this working, where you guys may have. Would be nice if we can make this work without having the complete package. Simply don't need EVERYTHING. Just the database and it's paginator would save me lots of time. The database is saving me a lot of time already, so hope this paginator will too :)
Thanks so far!
Yes..that's expected. The code simply bind paginator to a class, but it doesn't resolve dependencies for the classes that the paginator uses.
I might have sometime this week, but I can't promise you anything. I'm sure it's gonna be fun though :)
Yeah, would have thought. I'm not that familiar yet with all this, that's why I can't figure out what to do next. If you could find some time, that would be great. Fun seems to be good eh? ;-)
Perhaps if others can jump in too, would be cool. I'm sure you're not the only professional around.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community