Package Data | |
---|---|
Maintainer Username: | mixaster |
Maintainer Contact: | matt.fox@theplanworks.com (Matt Fox) |
Package Create Date: | 2017-02-16 |
Package Last Update: | 2017-03-02 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-09 15:01:32 |
Package Statistics | |
---|---|
Total Downloads: | 843 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 6 |
Total Watchers: | 3 |
Total Forks: | 1 |
Total Open Issues: | 0 |
This package allows users to easily consume the REST API provided by the Directus Headless CMS system in any Laravel app.
Install via composer using the command line:
composer require theplanworks/directus-laravel
In Laravel 5, update the config/app.php
providers array with the Service Provider:
thePLAN\DirectusLaravel\DirectusLaravelServiceProvider::class,
By default, the package is set up to use the following configuration values read from your .env
file:
DIRECTUS_CMS_URL
- The base URL of your CMS instance.DIRECTUS_API_KEY
- The key generated by the CMS and associated with a valid user that authenticates requestsIf you would like to use a config file, you can publish the default config by running the following command:
php artisan vendor:publish --provider="thePLAN\DirectusLaravel\DirectusLaravelServiceProvider"
This will publish a config file to config/directus-laravel.php
.
To utilize the API Wrapper, use dependency injection to resolve:
public function __construct(DirectusLaravel $directusAPI)
{
$this->api = $directusAPI;
}
Then you can make the following calls:
$value = $this->api->getTableRows($table);
Where $table
is the name of the Directus table you would like to access.
$value = $this->api->getTableRow($table, $id);
Where $table
is the name of the Directus table you would like to access, and $id
is the unique ID of the record being requested.
$value = $this->api->getTableRowBySlug($table, $slug)
Where $table
is the name of the Directus table you would like to access, and $slug
is the unique slug property of the record being requested. PREREQUISITE: A slug
field must have been created on the table.
$this->api->getFile($url);
Where $url
is the file url you would like to return, such as /storage/uploads/00000000001.png
.
This package is open-sourced software licensed under the MIT license.