Download the PHP package onpage-dev/onpage-php without Composer
On this page you can find all versions of the php package onpage-dev/onpage-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package onpage-php
On Page ® PHP library
With this library you can easy query your data using an On Page ® API token.
Installation
To install this library in your existing composer project, or update to the latest version, you can launch:
Of course, remember to include the composer autoload:
Usage
Setup
To start, you need to connect to an On Page Schema (project) using the following function:
Query your data
Filters and deletions
Get thing values
Use the val() function to get the first value in a field. Use the values() function to get all values in a field as a collection.
Files
For image
and file
fields, the returned value will be an instance of \OnPage\File::class
.
To get a file or image url use the ->link()
function. The link will point to the original file.
To turn images into a thumbnail add an array of options as shown below:
Other utilities
Get thing relations
Creating and updating things
To create or update a record, you need to create a Thing Editor. There are two ways to get a Thing Editor:
- Using the Resource Writer
- Calling
->editor()
on aOp\Thing
Using the Resource Writer (first method)
This class allows you to edit many records at once. You can easily obtain the editor calling:
Now that you have a Resource Writer, you can use it to create things:
...and to update existing things:
Finally, you need to send the request to the On Page server:
Updating a single item (second method)
Limiting modified languages
By default, even if you update a single language, the writer will delete the data on other languages. If you only need to edit certain languages and maintain the current values for the others, you can specify which languages you are working on as follows:
Updating translations
Just add the language code as the third argument to the set
function:
Updating files
You can upload files to On Page using the FileUpload class:
Or you can also upload a file using a public URL:
Updating multivalue fields
For multivalue fields you only need to replace ->set
with ->setValues
and pass an array of values as the second argument:
Updating relations
To update relations, you can use the ->setRel(relation_name, related_ids)
:
Get structure information
All versions of onpage-php with dependencies
guzzlehttp/guzzle Version ^7.9 || ^6.0
illuminate/collections Version ^8 || ^9 || ^10 || ^11