Project 6 - Snowboard site built with Symfony Framework.
Mandatory :
PHP >= 7.4
Symfony CLI
npm
oryarn
Optional :
Make
to use the Makefile and custom commandsDocker
andDocker-compose
for MySQL database and PhpMyAdmin containersMailDev
to catch emails (registration and lost password), or another mailcatcher
Unit Tests :
PHPUnit
-
To get this project on your local machine, simply clone this repository :
git clone [email protected]:OlivierFL/snowtricks.git
-
Install the dependencies :
-
composer install
-
npm install
or if Make is installed on your machine :
-
make deps-install
will run the above commands automatically.
-
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 theMAILER_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
-
After configuring the database connection, run
bin/console doctrine:database:create
to create the database. -
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
). -
Build the assets for development with
npm run dev
, ornpm run watch
to recompile every time a file is changed (CSS or Javascript). To build for production, runnpm run build
. The documentation for WebpackEncore is available on Symfony documentation page. -
Start the Symfony server with
symfony server:start
.
The homepage is available on : localhost:8000
.
List of useful commands to use the project :
symfony server:start
to start the Symfony serversymfony server:stop
to stop the Symfony servernpm run dev
to build the assets for dev environmentnpm run watch
to re-build the assets every time a CSS or Javascript file is modifiednpm run build
to build the assets for productionmaildev --hide-extensions STARTTLS
to start MailDev, if installed, available onlocalhost: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 servermake up-dev
to start Docker stack (MySQL and PhpMyAdmin) and Symfony server and build assets for dev environmentmake up-watch
to start Docker stack (MySQL and PhpMyAdmin) and Symfony server, build assets for dev environment and watch files changesmake mail
to start MailDev, available onlocalhost:1080
make down
to stop Docker stack (MySQL and PhpMyAdmin) and Symfony server
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.
Packages and bundles used in this project :
- FOSJsRoutingBundle
- KnpPaginatorBundle
- RollerWorks PasswordStrengthBundle
- SymfonyCasts ResetPasswordBundle
- SymfonyCasts VerifyEmailBundle
- WebpackEncore for building assets (
CSS
andJavascript
files) - TailwindCSS as CSS framework
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.
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.
PhpUnit is used to run the tests.
In a terminal, at the root of the project, run vendor/bin/phpunit
.
Links to code quality tools used for this project:
Codeclimate : https://codeclimate.com/github/OlivierFL/snowtricks
SonarCloud : https://sonarcloud.io/dashboard?id=OlivierFL_snowtricks