Skip to content

ld-web/medium-sf-di-solid-geocoding

Repository files navigation

Using dependency injection and SOLID principles with Symfony : The Geocoding example

Example app made for a Medium article.

The scope of the article is only Dependency Injection & SOLID principles. That's why you won't find :

  • Authentication system
  • Fixtures
  • Unit/Functional tests
  • Advanced error handling

Configuration

In your .env.local file, put the following vars :

DATABASE_URL=mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7

GOOGLE_MAPS_API_KEY=xxxxxxxxxxxxxx

Countries

A countries.csv file is available in the data directory. Don't hesitate to implement your own fixtures method in order to automate countries integration into your database.

I didn't do it here because it's not the scope of the article, but I figured it would be cool to have the file and the possibility to do it yourself.

Event Subscriber

The Event Subscriber is implemented into src\EventSubscriber\DestinationCoordinatesSubscriber.php.

It will trigger on prePersist & preUpdate.

About

Example app for a Medium article

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published