Download the PHP package daa/addressable-bundle without Composer
On this page you can find all versions of the php package daa/addressable-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download daa/addressable-bundle
More information about daa/addressable-bundle
Files in daa/addressable-bundle
Package addressable-bundle
Short Description Symfony bundle to make entities addressable and geo spacial services for searching and comparing their latitude/longitude
License
Informations about the package addressable-bundle
Symfony Addressable Bundle
This is a Symfony bundle which facilitates making entities addressable and geo location aware.
It includes a google map form type to search for and set addresses (with lat/lng), and a geo spatial service to ease calculating distances, sorting and filtering within a radius, etc using these objects with latitude and longitude.
Installation Symfony 5/6
Add the following to composer.json:
Register the bundle in your config/bundles.php
:
Include the twig template for the type layout in config/packages/twig.yml
Installation Symfony 2/3
Add the following to composer.json:
Register the bundle in your app/AppKernel.php
:
Include the twig template for the type layout in app/config/config.yml
Usage
Now your entity or document must:
- implement the included AddressableInterface
- use the relevant trait (ORM or PHPCR version) or manually reproduce the required fields, getters and setters
Note, if you are using an older version of PHP which does not support traits, then you are forced to copy the trait code manually into your entity.
Once your entity is setup, we can add the address map selector to your forms in the following ways:
Note: if using address as a child or relation remember to set the 'data_class' options pointing to the Address object.
Options
We can override several options:
Country Features
If you use "country" type (Symfony\Component\Form\Extension\Core\Type\CountryType) for the "country_field" the geospatial helper uses googles returned shortcode to populate the country short code in the dropdown
Further Customization
If you don't want the bundle to use it's own script you can override the address_map_scripts block to be empty; and then simply copy and paste the javascript in vendor/daa/addressable-bundle/Resources/public/js/address_map.js to your own js files.
To add additional functionality after address updates, simply override the block address_map_callback and extend to add the additional functionality (or make it empty and define var gmap_callback in your js code).
Screenshot
Sonata implementation:
Geospatial Helper Service
From your controller you can get the the addressable_bundle.geospatial_helper service; from anywhere else you can instantiate the GeospatialHelper class directly.
Examples:
All versions of addressable-bundle with dependencies
symfony/form Version >3.0
symfony/http-kernel Version >3.0
symfony/dependency-injection Version >3.0
symfony/config Version >3.0
symfony/validator Version >3.0
symfony/options-resolver Version >3.0