In this task used the database from data.sfgov.org site. This solution was selected because the data from the given CSV file and data is not equal. Anyway, the data was indexed by local SOLR platform. The goal of this example is show us how we can use Solr for searching some places near us. In this example is mobile food facility. On the home page we see all indexed data from Solr. It is the worst solution, but response from API server is too long and I have limited time for creating entities on internal side. If we put an address in the input field and after that submit the form, we will show the mobile food places near us at 0.5 km. if we click on the facility title we will go to the description page.
This task was realised by Symfony framework because I had 3 solutions: Drupal, Symfony and Node.JS. The Drupal is not suitable for this kind of tasks. Node.js will take more time for working with SOLR platform, and the choosing was on Symfony.
- Install Symfony CLI. For this we can use official documentation.
- Install Docker-compose using official [documentation] (https://docs.docker.com/compose/install/).
- Make a local clone of this repository:
git clone git@github.com:seyallin/mobileFoodFacility.git project_name
- Go to the project folder
cd project_name
- Run docker container from command:
docker-compose up -d
- On this step might need to run the command:
sudo chown 8983 solr/data -R
for the container accessing to the local folder solr/data. - Install the symfony project:
composer install
. - Run script for creating indexes:
bin/console solr:indexing
- Run local server using symfony tool:
symfony server:start
- Check the for using address:
2045 EVANS AVE
- Checking the Address description by clicking on facility link.
- Stop server:
symfony server: stop
- Prepare environment: 1h
- Coding: 2h
- Testing 0.5h
- Documentation 0.6h
Unfortunately, I wasted the time limits on 3h. The main issue was the development and testing of Solr part because I was stuck on moment when I wouldn't understand why the descriptions not loaded correctly. The reason of this issue was different between CSV file and external database, as result I declined to use CSV file.
- For extending of this example I want cover this project by caching, and testing.
- Also, I would like to add styles, The front part rebuild to the react Js solution.
- Migrate data from json to the internal database and do develop the entities related to this data.
- Extend the search form by filtering fields.
- Put all configurations to the config folder.
src/Comand/SolrIndexing.php
- class for Symfony CLI. Make console command for indexing data to solr side.src/Controller/HomeController
- controller class for the home page router.src/Controller/MobileFoodDetaileController
- controller class for the mobile food detail page router.src/Form/MobileFoodListType.php
- form class for the home page with searching form.src/Service/GeoApi.php
- GeoApi class for getting geolocation information by address. It is using the free external API.src/Service/JsonData.php
- service of working with json data. It was used for getting data from the external data API with JSON format response.src/Service/MobileFood.php
- service for getting data from external storage data.sfgov.org.src/Service/Solr.php
- service of working with solr side.templates/home/index.html.twig
- Home page template.templates/mobile_food_details/index.html.twig
- Mobile food detail page template.templates/base.html.twig
- base template that was extended in other templates.
For the Solr working, I used PHP Solr Client that has good documentation and is easy to work.