-
Dans votre base de données
training_db
, ajoutez les colonnes suivantes dans la tableusers
:- password VARCHAR(255)
- api_token VARCHAR(255)
-
Créez une page HTML d'inscription à votre service d'API, contenant uniquement un formulaire avec les champs suivants :
- Mot de passe
-
Confirmation du mot de passe
Utiliser l'outil Symfony CLI :
symfony new project_name --version=6.4 --webapp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parameters: | |
#... | |
app.api_gmaps_base_url: 'https://maps.googleapis.com/maps/api' | |
services: | |
#... | |
App\Geocoding\GoogleMapsGeocoding: | |
arguments: | |
$baseUrl: '%app.api_gmaps_base_url%' | |
$apiKey: '%env(GOOGLE_MAPS_API_KEY)%' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parameters: | |
#... | |
services: | |
#... | |
App\Geocoding\IGeocoding: '@App\Geocoding\OsmGeocoding' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// File : src/Controller/DestinationController.php | |
//... | |
use App\Geocoding\IGeocoding; | |
class DestinationController extends AbstractController | |
{ | |
//... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// File : src/Geocoding/OsmGeocoding.php | |
//... | |
class OsmGeocoding implements IGeocoding | |
{ | |
public function getLatLng(string $location): ?LatLng | |
{ | |
//... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// File : src/Geocoding/IGeocoding.php | |
namespace App\Geocoding; | |
use App\Entity\LatLng; | |
interface IGeocoding | |
{ | |
public function getLatLng(string $location): ?LatLng; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Geocoding; | |
use App\Entity\LatLng; | |
use Symfony\Contracts\HttpClient\HttpClientInterface; | |
class OsmGeocoding | |
{ | |
private $client; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// File : src/Geocoding/OsmGeocoding.php | |
class OsmGeocoding | |
{ | |
//... | |
public function geocode(string $location): ?LatLng | |
{ | |
$response = $this->client->request( | |
'GET', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parameters: | |
app.api_osm_base_url: 'https://nominatim.openstreetmap.org' | |
services: | |
#... | |
# add more service definitions when explicit configuration is needed | |
# please note that last definitions always *replace* previous ones | |
App\Geocoding\OsmGeocoding: | |
arguments: |
NewerOlder