mirror of
https://github.com/jonathan-martz/pocketbase-php-sdk.git
synced 2026-04-03 07:27:42 +00:00
Initial commit
This commit is contained in:
21
composer.json
Normal file
21
composer.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "mkay-development/pocketbase-php-sdk",
|
||||||
|
"license": "MIT",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jonathan Martz",
|
||||||
|
"role": "Maintainer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"autoload": {
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "src/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^8.1|^8.2",
|
||||||
|
"ext-curl": "*"
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/Pocketbase.php
Normal file
24
src/Pocketbase.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
class Pocketbase
|
||||||
|
{
|
||||||
|
private string|bool $response;
|
||||||
|
private string $url;
|
||||||
|
|
||||||
|
public function __construct(string $url)
|
||||||
|
{
|
||||||
|
$this->response = '{}';
|
||||||
|
$this->url = $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collection(string $collection, int $page = 1)
|
||||||
|
{
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $this->url."/api/collections/".$collection."/records?page=".$page);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
$this->response = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
return json_decode($this->response, JSON_FORCE_OBJECT);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user