Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Jackvdb's avatar

Accessing php classes in vue

I'm working on a laravel vue project where i make a get request to a 3rd party API to get all orders of a company The api has a limit of 100 orders per get request and they require you to use offset to get the next 100 Therefore i want to use pagination but this is new for me, so i'm not sure how to go about this

Currently i'm making a get request in my php Client class and I'm also building a pagination component in Vue If i understand this correctly i somehow need to access the orders array returned from the Client inside the pagination component to say that if orders length equals 100 the offset in my client should now be 100 etc etc

Is this the way to do this? If so, is there any way to access the methods in php from inside a vue component? ( client to server side )

Hope i'm being clear

0 likes
3 replies
tykus's avatar

is there any way to access the methods in php from inside a vue component

Only using through a Request to an endpoint/route in your application.

orders length equals 100 the offset in my client should now be 100

Not necessarily; you might be on page > 2 already. Does the API respond with anything useful that your paginator can use?

Jackvdb's avatar

Unfortunately no, just an array containing orders, nothing more

tykus's avatar
tykus
Best Answer
Level 104

In that case, the only thing you can know is there are no additional pages if there are less than 100 records in the array for a given request. I don't know that your paginator will be particularly useful if you cannot provide the basic information about the length of the dataset, or the current page. The only option in that scenario is to keep an internal (to your server-side application) count of the current page (and therefore the offset for the previous and next requests assuming simple prev and next links).

Please or to participate in this conversation.