inigo-aldama / inmovilla-api-client-bundle
Symfony bundle to integrate Inmovilla API client
Installs: 41
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.4 || ^8.0
- inigo-aldama/inmovilla-api-client: ^1.0
- symfony/framework-bundle: ^5.4 || ^6.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- symfony/dependency-injection: ^5.4 || ^6.0
README
inmovilla-api-client-bundle
is a Symfony package designed to integrate and simplify the use of the inmovilla-api-client
library within Symfony applications. It provides simplified configuration and pre-configured services to interact with the Inmovilla API.
Note: This project is not affiliated with Inmovilla.
Features
- Direct integration with
inmovilla-api-client
. - Simplified configuration through Symfony configuration files.
- Ready-to-use dependency injection for services and controllers.
- Predefined repositories for entities like cities, zones, and properties.
Requirements
- PHP: 7.4 or higher.
- Symfony: 5.4 or higher.
- Composer: For dependency management.
Installation
Install the package using Composer:
composer require inigo-aldama/inmovilla-api-client-bundle
Register the bundle automatically (Symfony Flex will handle it by default) or add it manually in config/bundles.php
:
return [ // Other bundles... Inmovilla\ApiClientBundle\InmovillaApiClientBundle::class => ['all' => true], ];
Configuration
Configure the API parameters in the config/services.yaml
file or .env
:
YAML Configuration
Add the following parameters in config/packages/inmovilla_api_client.yaml
:
inmovilla_api_client: api_url: "https://api.inmovilla.com/v1" domain: "your-domain.com" agency: "your-agency" password: "your-password" language: 1
.env Configuration
Alternatively, use environment variables in .env
:
INMOVILLA_API_URL="https://api.inmovilla.com/v1" INMOVILLA_DOMAIN="example.com" INMOVILLA_AGENCY="my-agency" INMOVILLA_PASSWORD="my-password" INMOVILLA_LANGUAGE=1
The inmovilla.api_client_config
service will be created automatically with this configuration.
Usage
Repository Injection
Repositories are ready to use in your services and controllers:
namespace App\Controller; use Inmovilla\Repository\CiudadRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; class MyController extends AbstractController { private CiudadRepository $ciudadRepository; public function __construct(CiudadRepository $ciudadRepository) { $this->ciudadRepository = $ciudadRepository; } public function index() { $cities = $this->ciudadRepository->findAll(); // Do something with the cities } }
Customizing Repositories
You can extend existing repositories to add specific logic:
namespace App\Repository; use Inmovilla\Repository\PropiedadRepository; class CustomPropertyRepository extends PropiedadRepository { public function findWithGarage(): array { return $this->findBy(['garage' => true]); } }
Available Services
The following services are available in the container:
Inmovilla\ApiClient\ApiClientInterface
: Main API client.Inmovilla\Repository\CiudadRepository
: Repository for cities.Inmovilla\Repository\ZonaRepository
: Repository for zones.Inmovilla\Repository\PropiedadRepository
: Repository for properties.Inmovilla\Repository\PropiedadFichaRepository
: Repository for property details.
Testing
Run the tests to validate the bundle:
./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
- Repository: inmovilla-api-client-bundle