Download the PHP package amanank/hal-client without Composer
On this page you can find all versions of the php package amanank/hal-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package hal-client
HAL API Client
A PHP client for interacting with HAL APIs. Tested with Laravel 8–12.
Installation
1. Install via Composer
You can install the package via Composer. Run the following command in your terminal:
If you haven't already, make sure to include the Composer autoload file in your project:
2. Publish the Configuration File
After installing the package, you can publish the configuration file using the following Artisan command:
This will create a configuration file named hal-client.php in your config directory.
Note
Laravel's auto-discovery feature will automatically register the HalClientServiceProvider for you. You do not need to manually register it in your config/app.php file. For local development in this monorepo, the package is available via a path repository (packages/*/*) with symlinks enabled, so you can edit the package in place; in CI/prod, Composer will fall back to Packagist.
3. Configure hal-client.php
After registering the service provider, you need to configure it. Create a configuration file named hal-client.php in your config directory with the following content:
Make sure to set the HAL_API_BASE_URI and HAL_API_TOKEN environment variables in your .env file:
4. Generate Models
To generate models from your HAL API, run the following commands in your terminal:
This will generate the necessary models based on your HAL API schema and ensure they are properly autoloaded.
Usage
Basic Usage
After generating the models, you can use them directly from the Amanank\HalClient\Models\Discovered namespace or extend them in your App\Models namespace.
Using Models Directly
Extending Models
You can also extend the generated models in your App\Models namespace:
Creating and Updating Models
Searching Models
You can get models using the Model::get method, which accepts parameters $page = null, $size = null, and $sort = null, and returns a LengthAwarePaginator.
Additionally, any search methods exposed by the HAL API can be used directly. For example, User::findByLastName returns a collection, and User::getByEmail returns a User or null.
Working with Relationships
Working with Enums
Enums are located under the Amanank\HalClient\Models\Discovered\Enums namespace and are prefixed with the model name, such as UserStatusEnum and PostStatusEnum.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes.
- Commit your changes (
git commit -am 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Create a new Pull Request.
Support
If you have any questions or need support, please open an issue on the GitHub repository.
All versions of hal-client with dependencies
illuminate/support Version ^8.0|^9.0|^10.0|^12.0
guzzlehttp/guzzle Version ^7.0
illuminate/filesystem Version ^8.0|^9.0|^10.0|^12.0