Download the PHP package lfvcodes/microbridge-php without Composer
On this page you can find all versions of the php package lfvcodes/microbridge-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lfvcodes/microbridge-php
More information about lfvcodes/microbridge-php
Files in lfvcodes/microbridge-php
Package microbridge-php
Short Description PHP's lightweight microservice communicator
License MIT
Homepage https://github.com/lfvcodes/microbridge-php
Informations about the package microbridge-php
MicroBridge-PHP
PHP's lightweight microservices/API communicator
MicroBridge-PHP is a lightweight (less than 500 lines of code) PHP 7.1+ tool for issuing internal API requests without network overhead.
Features
- Lightweight: Less than 500 lines of code
- Zero Dependencies: No external dependencies required
- PHP 7.1+ Compatible: Works with modern PHP versions
- Multiple HTTP Methods: Supports GET, POST, PUT, PATCH, DELETE
- State Management: Preserves and restores PHP superglobals
- Error Handling: Comprehensive error handling and validation
- Stream Simulation: Mock php://input stream for request body handling
Requirements
- PHP 7.1 or higher
- Composer (recommended) or manual installation
Installation
Using Composer (Recommended)
Install by running:
Manual Installation
If you're not using Composer, you can manually integrate MicroBridge into your project by following these steps:
1. Copy the Files
Download or clone the repository and copy the src/ folder into your project:
2. Manually Include the Classes
In your main file (index.php or similar), include the class file and use the namespace:
Usage
Basic POST Request
GET Request with URL Parameters
Advanced Usage with Headers
Running Examples
The examples/ directory contains working demonstrations of MicroBridge functionality. These examples are fully runnable and show real-world usage patterns.
Available Examples
basic-usage.php- Demonstrates fundamental GET, POST, PUT requestschained-requests.php- Shows how to chain multiple API calls togethererror-handling.php- Illustrates comprehensive error handling scenarios
Running Examples via Command Line
Navigate to the project root directory and run any example:
Running Examples via Web Server
If you have a local web server (Apache, Nginx, or PHP's built-in server) configured to serve PHP files:
Example Output
When running basic-usage.php, you should see clean HTML output demonstrating:
- Successful GET requests with chained API calls
- POST request handling with JSON payloads
- PUT requests with custom headers
- Proper error handling for invalid methods
All examples include the working API endpoints (api/api1.php and api/api2.php) that demonstrate real internal API communication without network overhead.
API Methods
| Method | Description | Use Case |
|---|---|---|
GET |
Retrieve data | Fetching resources |
POST |
Create new resource | Creating new records |
PUT |
Update entire resource | Full resource updates |
PATCH |
Partial update | Updating specific fields |
DELETE |
Remove resource | Deleting records |
Development
Running Tests
Code Style Checking
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.
Acknowledgments
- Built for modern PHP microservice architectures
- Inspired by the need for lightweight internal API communication
- Designed with simplicity and performance in mind