Grocery CRUD by default use the same URL that was initially called. As Grocery CRUD is actually an API at the backend, it is very common to want to change the URL path. For this the usage of
setApiUrlPath is required. This functionality also give the opportunity to have the basic page as static and to have the Grocery CRUD Api to a completely different place.
As people may still be confused of what the
setApiUrlPath is doing let's have an example.
The current page is loaded on the URL:
https://www.grocerycrud.com/docs/set-api-url-path, however this page is cached and the routes are a bit more complicated than you may think!
In fact our api is served to a different server so the function
setApiUrlPath is crucial to see all the examples that we have on our website 😃
So for this page specifically we are using the below line:
You can see the full code below:
$crud->setTable('customers'); $crud->setSubject('Customer', 'Customers'); $crud->fields(['customerName','phone','addressLine1','creditLimit']); $crud->setApiUrlPath('https://demo.grocerycrud.com/set-api-url-path'); $output = $crud->render();
You can see the results of the above code here: