Download the PHP package alantiller/directus-php-sdk without Composer
On this page you can find all versions of the php package alantiller/directus-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alantiller/directus-php-sdk
More information about alantiller/directus-php-sdk
Files in alantiller/directus-php-sdk
Package directus-php-sdk
Short Description The Slations unofficial PHP SDK for Directus 9
License MIT
Informations about the package directus-php-sdk
Directus PHP SDK
The PHP SDK for Directus 9 (@directus/directus)
Documentation
Installation (Composer)
We're now on packagist!!! Making installation even easier, all you have to do is include our package alantiller/directus-php-sdk
in your composer.json
file ^1.0
for the version and then run composer update.
Or you can run composer require alantiller/directus-php-sdk
and that will do all of the above for you :)
Installation (Manual)
To install the Directus PHP SDK is super simple and easy. All you need to do is download the latest release from the releases page and place the PHP file in your
Usage
We've simplified the way you create a newinstance of the SDK, now you set the config settings in the construct rather than another function. You can still define the other variables as before in the construct as below.
Personally I perfer to set the namespace when creating a new instance as I think it is cleaner but it's down to personal preference.
Config Options
Setting the options
There are currently four config options a user can set, these need to be set in the order below. Options with a start by the title are required the rest are optional.
Option 1* | Set API URL
You set the root URL to your directus installation, this field is required for the SDK to work.
Option 2* | Set Auth Prefix
You set the auth prefix for your directus instance, this is so the SDK can differentiate between two instances running in parallel
Option 3 | Set Auth Storage
The default is currently _SESSION
but can be changed the the following options to fit the end users needs.
_SESSION
- This stores the three Auth variables in a PHP Session on the server-side this is the most secure method but requires you to define a session session_start();
_COOKIE
- This stores the three Auth variables in Cookies on the client-side but will still store and use PHP Session on the server-side due to limitations in PHP Cookie support. This can be useful if you need to retreve the access token from JS using cookies.
Option 4 | Set Auth Domain
This one is only used if option 2 has been set to _COOKIE
. This sets the root auth domain of the cookie. By default it is /
so it applies to the whole site but can be set to a folder if you only want the user to be authenticated in the subdirectory.
Option 5 | Set Strip Headers
This option is mainly for development which is why it has been put at the end but the request passed back to the user can contain the headers as well as the content in the array. The default value is true
but can be set to false
if you need access to the headers of the request.
Global
Getting the API URL
Items
Create a Single Item
Read All Items
Read By Query
Read By Primary Key
Update Single Item
Delete an Item(s)
Auth
Get / Set Token
Setting a static auth token, if someone authenticates their authentication will override this auth token!
Login
When you submit a login request it will either respone with en error "errors" or it will just return true. If it has returned try then the login was successful and the Auth has been stored using the method defined in the config (_SESSION by default). The login with AutoRefresh so you will not need to worry about the token expiring.
Refresh
By default the SDK will auto refresh every fifteen minuites so the token is never expired. We will add the ability to turn off autoRefresh in the future.
Logout
Request a Password Reset
The second value is optional if you want to sent a custom return URL for the reset email.
Reset a Password
Note: the token passed in the first parameter is sent in an email to the user when using auth_password_request
All versions of directus-php-sdk with dependencies
php Version ^7.0 || ^8.0