|
| 1 | +# Installation |
| 2 | + |
| 3 | +## Plugin (recommended for newcomers) |
| 4 | +```shell |
| 5 | +composer require satur.io/duckdb-plugin |
| 6 | +``` |
| 7 | + |
| 8 | +This will install the `satur.io/duckdb-plugin` package, |
| 9 | +and it's the simplest way to have all the required resources at once. |
| 10 | + |
| 11 | +The plugin installs `satur.io/duckdb` and download the necessary DuckDB C library for your OS. |
| 12 | + |
| 13 | +You will need to trust `satur.io/duckdb-plugin` to execute code for this installation method. |
| 14 | + |
| 15 | +You can check the plugin source code [in its repo](https://github.com/satur-io/duckdb-plugin). |
| 16 | + |
| 17 | +If for any reason you don't want to use the plugin, or you prefer a customizable installation, |
| 18 | +please use any of the advanced installation options. |
| 19 | + |
| 20 | +## Advanced installation options |
| 21 | + |
| 22 | +Basically, to use this library you need the `satur.io/duckdb` package |
| 23 | +and the official C library files provided by DuckDB (both the header file and the binary). |
| 24 | + |
| 25 | +Unfortunately, C libraries are OS and platform dependant. Also, the header file needs some changes |
| 26 | +to be used in PHP via FFI. |
| 27 | + |
| 28 | +For each `satur.io/duckdb` release (from v2.0 on), we include the |
| 29 | +fixed headers and the binaries for all supported platforms as assets. |
| 30 | + |
| 31 | +!!! quote |
| 32 | +You can take a look at `scripts/get_libraries.sh`, the script used to get the libraries |
| 33 | +and adapt the headers files, and `.github/workflows/release-libs.yml` the action to publish |
| 34 | +the assets. |
| 35 | + |
| 36 | +### Using the downloader script |
| 37 | + |
| 38 | +Install `satur.io/duckdb` |
| 39 | +```shell |
| 40 | +composer require satur.io/duckdb |
| 41 | +``` |
| 42 | + |
| 43 | +To download the C libraries for your OS-platform, we provide a simple script. |
| 44 | +The script downloads the required files for the current package version in the |
| 45 | +desired path: |
| 46 | + |
| 47 | +```shell |
| 48 | +./vendor/bin/install-c-lib |
| 49 | +``` |
| 50 | + |
| 51 | +After running the command, you should see a requirement for setting the `DUCKDB_PHP_PATH` |
| 52 | +environment variable to the path where you downloaded the library. |
| 53 | + |
| 54 | +### Downloading the library by yourself |
| 55 | + |
| 56 | +Install `satur.io/duckdb` |
| 57 | +```shell |
| 58 | +composer require satur.io/duckdb |
| 59 | +``` |
| 60 | + |
| 61 | +Download C library, for example: |
| 62 | +```shell |
| 63 | +mkdir -p ~/duckdb-macos-lib && curl -s -L https://github.com/satur-io/duckdb-php/releases/download/1.2.0-beta.1/osx-universal.zip -o /tmp/duckdb.zip && unzip /tmp/duckdb.zip -d ~/duckdb-macos-lib && rm /tmp/duckdb.zip |
| 64 | +``` |
| 65 | + |
| 66 | +As in the previous case, you need to set the `DUCKDB_PHP_PATH` |
| 67 | +environment variable to the path. |
| 68 | +```shell |
| 69 | +export DUCKDB_PHP_PATH=~/duckdb-macos-lib |
| 70 | +``` |
0 commit comments