Docs · Laravel · PHP

Frameworks

Laravel · PHP

Geocoding from PHP with Laravel's HTTP client.

Example

GeocodeController.phpphp
1<?php2// Laravel — config/services.php: 'orvia' => ['key' => env('ORVIA_API_KEY')]3use Illuminate\Support\Facades\Http;45$response = Http::withToken(config('services.orvia.key'))6    ->get('https://orviamaps.ir/api/v1/geocode', ['q' => 'شیراز']);78$place = $response->json('result'); // name, type, lat, lon, population910// Plain PHP works the same with curl or file_get_contents11// and an "Authorization: Bearer …" header.

Replace YOUR_API_KEY with a key from your account, or read it from an environment variable as shown.