From e6ce2ec650f5e63d3a74fb47e796be7b9553509d Mon Sep 17 00:00:00 2001 From: Martz Date: Sun, 5 Feb 2023 16:52:09 +0100 Subject: [PATCH] Initial commit --- composer.json | 21 +++++++++++++++++++++ src/Pocketbase.php | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 composer.json create mode 100644 src/Pocketbase.php diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..1166d59 --- /dev/null +++ b/composer.json @@ -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": "*" + } +} \ No newline at end of file diff --git a/src/Pocketbase.php b/src/Pocketbase.php new file mode 100644 index 0000000..2c5005b --- /dev/null +++ b/src/Pocketbase.php @@ -0,0 +1,24 @@ +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); + } + +}