This package provides a convenient way to interact with the Reqres API and handle user data.
To install UserApiHandler directly from GitHub, follow these steps:
- Add the following to your
composer.json
file:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/abbas-samadani/user_api_handler"
}
]
-
Run the following command to install the package:
composer require plentific/user-api-handler
-
Once the package is installed, you need to register the service provider in your
config/app.php
file:
'providers' => [
...
Plentific\UserApiHandler\Providers\UserServiceProvider::class,
...
]
The UserService class provides methods for accessing user data. Here are some examples:
use Plentific\UserApiHandler\UserController;
class PackageController extends Controller
{
private $controller;
public function __construct(UserController $controller)
{
$this->controller = $controller;
}
public function index()
{
// Get a single user by ID
$user = $this->controller->show(1);
// Get a paginated list of users
$users = $this->controller->index(1);
// Create a new user
$newUser = $this->controller->store('Ben', 'Developer');
}
}
For more usage details, refer to the source code.
Unit tests are included in the tests directory. To run the tests, use the following command:
vendor/bin/phpunit
If you need assistance or have any questions, please open an issue in the GitHub repository.
Contributions are welcome! If you'd like to contribute, please submit pull requests.
This package is licensed under the MIT License. See the License File for more information.