Skip to content

OlivierFL/snowtricks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maintainability Quality Gate Status

SnowTricks

Project 6 - Snowboard site built with Symfony Framework.

Requirements

Mandatory :

  • PHP >= 7.4
  • Symfony CLI
  • npm or yarn

Optional :

  • Make to use the Makefile and custom commands
  • Docker and Docker-compose for MySQL database and PhpMyAdmin containers
  • MailDev to catch emails (registration and lost password), or another mailcatcher

Unit Tests :

  • PHPUnit

Installation

  1. To get this project on your local machine, simply clone this repository :

    git clone [email protected]:OlivierFL/snowtricks.git
  2. Install the dependencies :

  • composer install

  • npm install

    or if Make is installed on your machine :

  • make deps-install will run the above commands automatically.

  1. Environment configuration :

    To configure local dev environment, create a .env.local file at the root of the project.

    To configure database connection, override the DATABASE_URL env variable with your database credentials and database name, for example :

    DATABASE_URL="mysql://root:[email protected]:3306/snowtricks?serverVersion=5.7"

    If you're using the MySQL Docker container, the config is :

    DATABASE_URL="mysql://root:[email protected]:3306/snowtricks"

    To enable sending registration and lost password emails, add in the .env.local file the MAILER_DSN env variable, for example with MailDev :

    MAILER_DSN="smtp://localhost:1025"

    In the .env file, 2 variables are available, to configure the default number of tricks displayed on homepage, and the number of comments displayed on each trick detail page :

    TRICKS_LIST_LIMIT=8
    COMMENTS_LIST_LIMIT=4
  2. After configuring the database connection, run bin/console doctrine:database:create to create the database.

  3. Import the example data set available in the dump directory in the database. If you're using Docker, PhpMyAdmin is available on localhost:8080 (user : root, password : admin).

  4. Build the assets for development with npm run dev, or npm run watch to recompile every time a file is changed (CSS or Javascript). To build for production, run npm run build. The documentation for WebpackEncore is available on Symfony documentation page.

  5. Start the Symfony server with symfony server:start.

The homepage is available on : localhost:8000.

Usage

List of useful commands to use the project :

  • symfony server:start to start the Symfony server
  • symfony server:stop to stop the Symfony server
  • npm run dev to build the assets for dev environment
  • npm run watch to re-build the assets every time a CSS or Javascript file is modified
  • npm run build to build the assets for production
  • maildev --hide-extensions STARTTLS to start MailDev, if installed, available on localhost:1080

Commands to use with Docker and Make (commands are available in Makefile at the root of the project) :

  • make up to start Docker stack (MySQL and PhpMyAdmin) and Symfony server
  • make up-dev to start Docker stack (MySQL and PhpMyAdmin) and Symfony server and build assets for dev environment
  • make up-watch to start Docker stack (MySQL and PhpMyAdmin) and Symfony server, build assets for dev environment and watch files changes
  • make mail to start MailDev, available on localhost:1080
  • make down to stop Docker stack (MySQL and PhpMyAdmin) and Symfony server

Sample data

In order to have a fully functional application, the SQL file contains :

  • 2 users with different states :

    • an admin user with [email protected] email, admin username and Admin1234 password. This user has role admin and can create, edit and delete any snowboard tricks, post comments and moderate comments in admin dashboard.

    • a simple user with [email protected] email, test username and Test1234! password. This user can create and edit any tricks, delete his own tricks, post comments.

  • A default list of Tricks with some example media and comments.

Third party libraries

Packages and bundles used in this project :

Docker (optional)

This project uses Docker for MySQL database and PhpMyAdmin.

The stack is composed of 2 containers :

  • mysql
  • phpMyAdmin

The configuration is available in the docker-compose.yaml.

Catching emails (optional)

Instead of sending emails to a real email address, a mailcatcher can be used. For this project, I used MailDev, installed locally, to catch emails.

The Symfony MAILER_DSN env variable configuration for MailDev is available in the installation part.

Tests

PhpUnit is used to run the tests.

In a terminal, at the root of the project, run vendor/bin/phpunit.

Code quality

Links to code quality tools used for this project:

Codeclimate : https://codeclimate.com/github/OlivierFL/snowtricks

SonarCloud : https://sonarcloud.io/dashboard?id=OlivierFL_snowtricks