inigo-aldama / inmovilla-api-proxy
A proxy server for interacting with the Inmovilla API, designed for environments with restricted IP access.
Installs: 41
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^7.4 || ^8.0
- ext-curl: *
- ext-json: *
- inigo-aldama/inmovilla-api-client: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.5
README
inmovilla-api-proxy
is a tool designed to solve a specific problem when interacting with the Inmovilla API: IP-based access restrictions.
Note: This project is not affiliated with, endorsed by, or maintained by Inmovilla.
Why Use Inmovilla API Proxy?
Inmovilla restricts access to their API to specific IP addresses. This becomes a problem when you're developing from a machine outside the allowed IP range. Here's how the situation looks:
-
Production server with
inmovilla-api-client
installed
✅ Can connect to the Inmovilla API (IP is allowed). -
Development machine with
inmovilla-api-client
installed
❌ Cannot connect to the Inmovilla API (IP is not allowed).
This package solves the issue by enabling the production server to act as a proxy. With inmovilla-api-proxy
installed on the production server:
- Your development machine sends requests to the production server (acting as the proxy).
- The production server forwards these requests to the Inmovilla API.
- The response from the Inmovilla API is sent back to your development machine.
How It Works
Here’s a visual representation of the interaction flow between the Development Server, Production Server, and the Inmovilla API:
Production Server
inmovilla-api-client
is installed to send API requests to Inmovilla.inmovilla-api-proxy
is installed to act as a proxy for requests from the development machine.
Development Machine
inmovilla-api-client
is installed to send requests to the proxy on the production server.
Example Flow
-
Without Proxy
- Development server → Direct connection to Inmovilla API → ❌ IP not allowed.
-
With Proxy
- Development server → Proxy on production server → Inmovilla API → ✅ Works.
Requirements
- PHP: 7.4 or higher.
- Composer: For dependency management.
- Libraries:
Installation
-
Install the Proxy on the Production Server Clone the repository or use Composer:
composer require inigo-aldama/inmovilla-api-proxy
-
Configure API Credentials Update the
api.ini
configuration file on both servers (development and production):api.ini
on the production server:api_url = "https://api.inmovilla.com/v1" domain = "production-domain.com" agency = "production-agency" password = "production-password" language = 1
api.ini
on the development server:api_url = "http://production-server-url/api-proxy" domain = "production-domain.com" agency = "development-agency" password = "development-password" language = 1
Usage
-
On the Production Server Deploy
inmovilla-api-proxy
with the following setup:<?php require 'vendor/autoload.php'; use Inmovilla\ApiClient\ApiClientConfig; use Inmovilla\Proxy\ProxyService; use GuzzleHttp\Client as GuzzleClient; use GuzzleHttp\Psr7\HttpFactory; $serverConfig = ApiClientConfig::fromIniFile(__DIR__ . '/config/api.ini'); $httpClient = new GuzzleClient(); $requestFactory = new HttpFactory(); $proxyService = new ProxyService($httpClient, $requestFactory, $serverConfig); $input = file_get_contents('php://input'); $response = $proxyService->handleRequest($input); header('Content-Type: application/json'); echo json_encode($response);
-
On the Development Machine Configure
api_url
to point to the production server's proxy, and useinmovilla-api-client
as usual.
Key Points
- The proxy must be installed on the production server; it's not needed on the development machine.
- The
api.ini
configuration must exist on both servers:- The production server uses the real Inmovilla API URL.
- The development machine points
api_url
to the proxy URL.
Data Sent to Inmovilla API
When using the proxy, the following data is sent to Inmovilla:
api_url
: From the production server.domain
: From the production server.agency
: From the development machine.password
: From the development machine.language
: From the development machine.
Testing
Run PHPUnit tests to validate functionality:
./vendor/bin/phpunit --testdox
Contribution
- Fork the repository.
- Create a new branch (
git checkout -b feature/new-feature
). - Commit your changes (
git commit -m 'Add new feature'
). - Push to your branch (
git push origin feature/new-feature
). - Open a pull request.
License
This project is licensed under the MIT License.
Credits
- Author: Iñigo Aldama Gómez
- Inmovilla API Client Repository: inmovilla-api-client