- Rate web page with js code snippet.
- Api endpoints for voting and getting data for current web page.
If you are new to symfony go learn with me: Blog
- Clone project
- Configure database and mailer in
app/config/parameters.yml
- Run commands from application root directory
composer install
php bin/console doctrine:database:create
php bin/console doctrine:schema:create
- You can add dummy data, run command from application root directory
php bin/console doctrine:fixtures:load
- Run commands from application root directory
php bin/console doctrine:database:create --env=test
php bin/console doctrine:schema:create --env=test
phpunit
- Run command from application root directory
npm install or yarn
- For development run command
npm run watch or yarn run watch
- For production run command
npm run production or yarn run production
If application is installed you can visit http://{your-site}/api/doc
for more information
Basic information
Request
{
"data": {
"uri": "some_uri",
}
}
Success response - status code 200
{
"status": "success",
"data": {
"uri": "some_uri",
"score": 4.12
}
}
Failure response - status code 400
{
"status": "failure",
"errors": {
"validation": {
"field-name": "validation-error-message",
}
}
}
Request
{
"data": {
"visitor_id": "some_visitor_id",
"uri": "some_uri",
"rating": 3
}
}
Success response - status code 200
{
"status": "success",
"data": {
"uri": "some_uri",
"rating": 3,
"score": 4.12
}
}
Failure response - status code 400
{
"status": "failure",
"errors": {
"validation": {
"field-name": "validation-error-message",
}
}
}
Roadmap:
-
Optimize tests
-
Add Dusk for functional tests ( https://gist.github.com/kbond/bf86368e46090fb2ffaec0e5cbe91ea8 )
-
Add console command to purge unrated sites (cron)
-
Add console command to sync sum users, sum rating and average score (cron)
- Use DQL for example:
SELECT ur.uri_id, u.uri, COUNT(DISTINCT ur.visitorId) voters, SUM(ur.rating) as sum_rating, avg(ur.rating) as page_rating FROM uri_rating ur JOIN uri u ON u.id = ur.uri_id GROUP BY ur.uri_id
-
add API option for getting domain rating based on domain page ratings
-
add API option for getting visitor site ratings
-
Refactor widget js ( visitors can change mind )
-
Visitor can only vote once per page ( server side implementation )
Symfony rating-app is open-sourced software licensed under the MIT license