Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin committed Dec 21, 2020
1 parent 33f9ec5 commit 76c596c
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
115 changes: 115 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
Happy Shop
==========

This repository contains all the code about the tutorial: [Building a Shopping Cart with Symfony 5](https://dev.to/qferrer/introduction-building-a-shopping-cart-with-symfony-f7h).

!['Shopping Cart View'](docs/happy-shop.png)

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

- [Getting Started](https://dev.to/qferrer/getting-started-building-a-shopping-cart-with-symfony-271e)
- [Managing Products](https://dev.to/qferrer/managing-products-building-a-shopping-cart-with-symfony-4n2)
- [Creating Cart Entities](https://dev.to/qferrer/creating-cart-entities-building-a-shopping-cart-with-symfony-h90)
- [Managing the Cart Storage](https://dev.to/qferrer/managing-the-cart-storage-building-a-shopping-cart-with-symfony-57o6)
- [Adding Products to the Cart](https://dev.to/qferrer/adding-products-to-the-cart-building-a-shopping-cart-with-symfony-103o)
- [Creating the Cart Page](https://dev.to/qferrer/creating-the-cart-page-building-a-shopping-cart-with-symfony-lcg)
- [Removing Products from the Cart](https://dev.to/qferrer/removing-products-from-the-cart-building-a-shopping-cart-with-symfony-3ebh)
- [Clearing the Cart](https://dev.to/qferrer/clearing-the-cart-building-a-shopping-cart-with-symfony-3o90)
- [Purging Expired Carts](https://dev.to/qferrer/purging-expired-carts-building-a-shopping-cart-with-symfony-3eff)
- [Testing the Cart](https://dev.to/qferrer/testing-the-cart-building-a-shopping-cart-with-symfony-476)

Requirements
------------

- PHP 7.2.5+
- [Composer](https://getcomposer.org/download)
- [Symfony CLI](https://symfony.com/download)
- [Docker & Docker compose](https://docs.docker.com/get-docker)

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](http://localhost:8000/), 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](http://localhost:8000/cart), click on the *Remove* button for the product you want to remove.

**Updating the quantity of products in the Cart**

From the [cart page](http://localhost:8000/cart), enter the desired quantity for the products and click on the *Save* button.

**Clearing the Cart**

From the [cart page](http://localhost:8000/cart), 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
```
Binary file added docs/happy-shop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 76c596c

Please sign in to comment.