Download the PHP package santosalan/api-magic without Composer
On this page you can find all versions of the php package santosalan/api-magic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download santosalan/api-magic
More information about santosalan/api-magic
Files in santosalan/api-magic
Informations about the package api-magic
API Magic
A PHP library that provides automatic and magical API client generation for REST APIs using dynamic method calls.
Features
- 🪄 Magic Methods: Automatically converts method calls to HTTP requests
- 🔧 Flexible Configuration: Easy setup for different API endpoints
- 🔐 Authentication Support: Built-in support for Basic Authentication
- 📡 HTTP Client: Uses Guzzle HTTP client for reliable requests
- 🎯 Route Verification: Optional route validation before making requests
- 📋 Multiple Formats: Support for JSON and form-encoded data
- 🏷️ Named Returns: Option to wrap responses with element names
Installation
Install via Composer:
Requirements
- PHP >= 5.5.0
- Guzzle HTTP >= 6.3.0
Basic Usage
Configuration
Basic Configuration
Authentication
Token-based Authentication
Advanced Usage
JSON Requests
Custom Headers
Named Element Returns
Route Verification
Method Parameters
When calling dynamic methods, you can pass up to 4 parameters:
Examples
Error Handling
Route Verification Response Format
If you enable route verification, your routes endpoint should return JSON in this format:
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Alan Santos
- Email: [email protected]
- GitHub: @santosalan
Keywords
PHP, API, Magic, Service, Automatic, Utilities, Guzzle, REST, HTTP Client
Practical Examples
Creating Custom API Clients
You can create specific API clients by extending the ApiMagic class: