Sport calendar is a web application, which helps athletes to track their progress at the gym. When athlete finishes an exercise, he came to the application to save the information. For example, he writes that he did leg press 8 times with weight 100kg. This data together with a timestamp is saved to database.
Then, on a dashboard athlete sees:
- what he did today,
- what he did a week ago (on the same weekday),
- what he did 2 weeks ago
In current task we will create only dashboard. There will be fixtures that add data for testing purpose, so we do not need any form to add exercises.
There is only one entity - Exercise.
Fields are:
- short description of done exercise
- weight,
- number of repetitions,
- date
- time
Fill the data model with fake data for testing. Use Nelmio Alice bundle to create following the fixtures:
- 3 types of exercises (short descriptions)
- Weight is random between 20 and 200kg.
- Repetitions are random between 5-15.
- Total amount of exercises done in last 30 days should be about 300-400.
Dashboard should be very simple – just some title and table with 3 columns, one for each date. If this project is success, it will require a mobile application with the same dashboard. So, all data should be fetched via service layer, to be reused later.
Try to implement this functionality without writing custom query It’s expected to have only one DB request for the whole page
Service class should have one public method to fetch all data needed for dashboard. This method should be covered with Unit test – all external calls from the service are replaced by mocks and service class is only one real object in the test, created via “new” operator.
Translate user interface into 2 languages: Russian and English. Locale should be defined by part of requested URL. For example, /en/calendar – is English dashboard, /ru/calendar – is Russian one.
Do not translate data, only interface.
# composer install
# php bin/console doctrine:database:create
# php bin/console doctrine:schema:update --force
# php bin/console server:run
php bin/console doctrine:fixtures:load
vendor/bin/phpunit
- Symfony Documentation - Entity
- Symfony Documentation - DoctrineFixturesBundle
- Alice - Expressive fixtures generator
- How to create a php service for symfony 2 & 3 with entity manager and service container
- Multilingual website with Symfony
- JMSI18nRoutingBundle
- Template from Nikhil Krishnan
- but specially my lovely husband