The NomadMedia SDK for PHP provides a simple, intuitive interface for interacting with the NomadMedia API. It supports authentication, content management, and utility methods to enable easy integration with the NomadMedia platform.
To install the SDK, use Composer:
composer require prisonfellowship/nomad-php-sdk
- PHP 8.1 or higher
- Composer
- Saloon v3.10.0 (for HTTP requests)
The following packages are required for development:
- Pest v2.35 (for testing)
- PHPStan v1.11 (for static analysis)
- Laravel Pint v1.17 (for code linting)
To initialize the SDK, create an instance of the NomadMediaConnector
with the necessary configuration options:
use PrisonFellowship\NomadPHPSDK\NomadMediaConnector;
$connector = new NomadMediaConnector([
'serviceApiUrl' => 'https://api.example.com', // Your API base URL
'username' => 'your_username', // For authentication
'password' => 'your_password', // For authentication
'apiType' => 'portal', // Can be 'portal' or 'admin'
'debugMode' => true, // Optional: Debug mode for logging API calls
]);
$response = $connector->login();
$token = $connector->getToken(); // Save the token
$connector->logout();
$response = $connector->refreshToken();
$token = $connector->getToken(); // Save the new token
$response = $connector->getDefaultSiteConfig();
print_r($response);
$response = $connector->getMediaGroup('0df0f00b-0b00-00c0-000e-0c0fca000ae');
print_r($response);
$connector->forgotPassword('your_username');
$connector->forgotPassword('your_username');
$username = 'your_username';
$token = 'reset_token';
$newPassword = 'new_secure_password';
$connector->resetPassword($username, $token, $newPassword);
If debugMode
is set to true
during initialization, the SDK will send detailed API request and response information to LaraDumps, allowing you to debug visually in real time with a clean and organized interface.
$connector = new NomadMediaConnector([
'serviceApiUrl' => 'https://api.example.com',
'debugMode' => true, // Enable debug mode with LaraDumps integration
]);
When debug mode is enabled, each request and response will be sent to the LaraDumps app in a dedicated screen. For example:
-
✅
Request
screen will show:- Endpoint
- HTTP Method
- Headers
- Body
- Query parameters
-
✅
Response
screen will show:- Status code
- Response body
To use this feature, you must install the LaraDumps Desktop App:
-
Download it from the official repository:
👉 https://github.com/laradumps/app/releases -
Install and run the app. It should run in the background and automatically receive logs.
-
(Optional) You can open dedicated screens inside the app to organize logs, such as “Request”, “Response”, etc.
This SDK uses Pest for testing. To run the tests:
- Install the development dependencies:
composer install --dev
- Run the tests:
composer test
- You can run Laravel Pint to check for coding standards violations:
composer run lint
- You can run PHPStan to perform static analysis on the codebase:
composer run analyse
Contributions are welcome! Please follow the steps below to contribute:
- Fork the repository.
- Create a new branch with a descriptive name (e.g.,
feature-new-method
). - Make your changes.
- Write tests for any new functionality or changes.
- Submit a pull request with a detailed description of your changes.
Please ensure your code adheres to PSR-12 coding standards.
You can run the linter to check for coding standards violations:
composer run lint
This SDK is open-source and available under the MIT License.