Skip to content

Instantly share code, notes, and snippets.

@xabbuh
Created May 1, 2018 21:16
Show Gist options
  • Save xabbuh/bb8b234a27e0e1226d73d826e04a4be1 to your computer and use it in GitHub Desktop.
Save xabbuh/bb8b234a27e0e1226d73d826e04a4be1 to your computer and use it in GitHub Desktop.

Tasks

Your task is to create two small applications that make use of a centralized product database:

  • application one provides a CLI command that reads CSV files into Product entities and stores them in a database (for example, by using Doctrine ORM)

  • the second application provides a simple web interface that allows users to browse the product catalog (for example, use a Bootstrap driven layout)

Based on the initial implementations make some improvements you are interested in the most (for all these tasks try to find existing packages or packs that help you fullfil the task with the at least self-written code as possible) either by modifying any of the existing applications or by creating a new one:

  • create an API that allows to retrieve (and maybe also modify or add) existing products

  • write a client implementation that consumes the API and displays the data being read

  • support different import formats (XML, JSON, etc.)

  • allow to export product data in different formats (XML, JSON, etc.)

  • create a simple admin UI that allows users to create/edit/delete products, as a bonus, seek to protect the admin interface to certain authenticated users

  • think about other data you would like to store with your products, create database migrations that sync your existing schema with the newly invented attributes

  • enrich the front-end with some more or less elaborated search that allows your users to filter the list of products

  • think about a service layer that abstracts some business logic related to your products, find out how to write tests for it

  • implement your own ideas

<?php
declare(strict_types = 1);
namespace App\Entity;
class Product
{
public $id;
public $name;
public $description;
public $price;
public $taxRate;
public static function fromArray(array $data): self
{
$instance = new static();
$instance->id = $data['id'];
$instance->name = $data['name'];
$instance->description = $data['description'];
$instance->price = $data['price'];
$instance->taxRate = $data['taxRate'];
return $instance;
}
}
id name description price taxRate
123 Soap Soap to wash your hands 299 19
234 Milk Milk to eat with cereals 119 7
345 Potatoes Potatos to cook and eat 199 7
456 Pizza Frozen pizza for lazy Sundays 219 7
567 Shirt To wear in summer 999 19
678 Lego To play with 2099 19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment