Skip to content

qferr/happy-shop

Repository files navigation

Happy Shop

This repository contains all the code about the tutorial: Building a Shopping Cart with Symfony 5.

'Shopping Cart View'

The tutorial describes the creation of a shopping cart with Symfony, from scratch and step by step:

Requirements

Getting started

Cloning the repository

$ git clone https://github.com/qferr/happy-shop
$ cd happy-shop/

Installing dependencies

$ composer install

Starting Docker Compose

$ docker-compose up -d

Loading fake Products

$ symfony console doctrine:fixtures:load

Launching the Local Web Server

$ symfony server:start -d

The server started on the port 8000. Open the website http://localhost:8000 in a browser.

Usage

Adding Products to the Cart

From the homepage, go to a product page by clicking on the View details button. Then set a quantity and click on the Add to Cart button.

Removing Products from the Cart

From the cart page, click on the Remove button for the product you want to remove.

Updating the quantity of products in the Cart

From the cart page, enter the desired quantity for the products and click on the Save button.

Clearing the Cart

From the cart page, click on the Clear button.

Purging Expired Carts

From the project directory, execute the following command in a terminal:

$ symfony console app:remove-expired-command

Testing

Configuring a Database for Tests

Create the database and update the database schema by executing the following command:

$ bin/console doctrine:database:create -e test
$ bin/console doctrine:migrations:migrate -e test

For now, the database is empty, load the products fixtures with:

$ bin/console doctrine:fixtures:load -e test

Executing tests

Run the tests with the following command:

$ bin/phpunit