Skip to content

Commit 1e992ad

Browse files
committed
1st commit my-quizz project
1 parent cf45647 commit 1e992ad

21 files changed

+114
-36
lines changed

.env

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ APP_SECRET=72672cbe3b541659872592257379cd59
2121
###< symfony/framework-bundle ###
2222

2323
###> symfony/mailer ###
24-
MAILER_DSN=smtp://c9b0e168394b05:e49da1659e52ce@smtp.mailtrap.io:2525/?encryption=ssl&auth_mode=login
24+
MAILER_DSN=smtp://user:key@smtp.mailtrap.io:2525/?encryption=ssl&auth_mode=login
2525
###< symfony/mailer ###
2626

2727
###> doctrine/doctrine-bundle ###
2828
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
2929
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
3030
# For a PostgreSQL database, use: "postgresql://db_user:[email protected]:5432/db_name?serverVersion=11&charset=utf8"
3131
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
32-
DATABASE_URL=mysql://root:Obrigada@localhost:3306/my_quizz?serverVersion=5.7
32+
DATABASE_URL=mysql://root:root@localhost:3306/my_quizz?serverVersion=5.7
3333
###< doctrine/doctrine-bundle ###

.github/preview/admin.png

326 KB
Loading

.github/preview/historyindex.png

143 KB
Loading

.github/preview/historyshow.png

413 KB
Loading

.github/preview/home.png

606 KB
Loading

.github/preview/indexquizz.png

952 KB
Loading

.github/preview/login.png

160 KB
Loading

.github/preview/profil.png

276 KB
Loading

.github/preview/register.png

218 KB
Loading

.github/preview/showquizz.png

637 KB
Loading

config/packages/security.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ security:
3636
access_control:
3737
- { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
3838
- { path: ^/admin, roles: ROLE_ADMIN }
39+
- { path: ^/profil, roles: ROLE_USER }
40+
- { path: ^/edit, roles: ROLE_USER }
41+
- { path: ^/user, roles: ROLE_USER }
3942
# - { path: ^/profile, roles: ROLE_USER }

public/style.css

+1
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ ul{
7171
button {
7272
margin : 20px 0 0 0;
7373
}
74+

readme.md

+96-18
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
# MVC_MY_Quiz
22

3-
Project realized with Symfony
3+
My first project with Symfony !
44

5-
## Start and quite the server in local
5+
* Register _(with email validation)_ and login
6+
* CRUD user _(with email validation when you change the password or email)_
7+
* Play quiz
8+
* See your quiz history _(if user is not authenticated, he can plays a quiz and see history)_
9+
10+
With the admin role :
11+
* CRUD question
12+
* CRUD response
13+
* CRUD category
14+
* CRUD user
15+
16+
[My app](https://my-quizz.sekhmset.me/)
17+
18+
## Versions
19+
20+
* PHP 7.4.5
21+
* Symfony 5.0.*
22+
* Composer 1.10.5
23+
24+
## In local
25+
### Start and quite the server
26+
27+
You need to have instal Symfony before use the following command in your terminal.
28+
To instal Symfony, refer you to the links at the end of this readme
629

730
```bash
831
symfony server:start
@@ -12,35 +35,90 @@ symfony server:start
1235
ctrl + c
1336
```
1437

15-
## versions
38+
### Database
39+
40+
Start migration to have all the tables :
1641

1742
```bash
18-
PHP 7.4.5
43+
php bin/console doctrine:migrations:migrate
1944
```
2045

46+
Don't forget to update your username, password and table in `.env`
47+
48+
**To deploy :** in your Google Cloud Platform create your database and an user
49+
50+
How to configure your variable ?
51+
```bash
52+
DATABASE_URL = mysql://username:password@localhost?unix_socket=/cloudsql/project_id:region:your_database;dbname=database_name
53+
```
54+
55+
### Admin
56+
I used `easyAdmin` a Symfony bundle.
57+
To install easyAdmin I followed the instructions of the documentation.
58+
59+
[Link of the documentation](https://symfony.com/doc/master/bundles/EasyAdminBundle/index.html)
60+
61+
## Mail
62+
### Dev env.
63+
[MailTrap](https://mailtrap.io/)
64+
65+
Create your inbox then update your config in `.env`
66+
67+
### Prod env.
68+
69+
[Sendgrid](https://sendgrid.com/)
70+
71+
Create the API Key then update your config in `.env`
72+
73+
*PS : if you don't receive the email think to check your indesirable email*
74+
75+
## Docker and Google Cloud
76+
77+
Create a `docker` directory, `docker-compose.yml` file and `.dockerignore`.
78+
In your docker directory you have to create the following folders : `Dockerfile` and `opcache.ini`
79+
80+
### Make your migration on cloud
81+
82+
Create a `.cloudbuild` directory and a `seeder-deploy.yaml` in this directory.
83+
2184
```bash
22-
Symfony CLI version v4.14.3
85+
EXPORT PROJECT_ID=your_project_id
86+
EXPORT DOCKER_IMAGE=your_docker_image
87+
EXPORT YOUR_TAG=name_of_your_tag
88+
89+
docker build -f docker/Dockerfile -t eu.gcr.io/${PROJECT_ID}/${DOCKER_IMAGE}:${YOUR_TAG} .
90+
docker push eu.gcr.io/${PROJECT_ID}/${DOCKER_IMAGE}:${YOUR_TAG}
2391
```
2492

93+
Start your migration with cloud build
94+
2595
```bash
26-
Composer version 1.10.5
96+
gcloud builds submit \
97+
--project ${PROJECT_ID} \
98+
--config .cloudbuild/seeder-deploy.yaml \
99+
--substitutions "_SERVICE=${DOCKER_IMAGE}:${YOUR_TAG},_REGION=europe-west1,_INSTANCE_NAME=my-sql-database,_DATABASE_URL=mysql://login_database:password_database@localhost?unix_socket=/cloudsql/${PROJECT_ID}:europe-west1:my-sql-database;dbname=db_name"
27100
```
28101

29-
## Admin
30-
I used `easyAdmin` Bundle
102+
### DNS and Google Analytics
103+
104+
If you want to use Google Analytics or somthing else create your property and configure it _(Google A.)_
105+
Then add the code at the end of the template : `base.html.twig`
106+
107+
To use a DNS add your DNS in your Cloud DNS and add a mapping to your service
31108

32-
## links
109+
## Links
33110

111+
- Link to download : [Link](https://symfony.com/download)
34112
- Link to install and configure Symfony : [Link](https://symfony.com/doc/current/setup.html)
35113
- Composer : [Link](https://getcomposer.org/)
36114

37-
# How to use it with docker
38-
## Make the migration on cloud
115+
## Preview
39116

40-
You have to create a `.cloudbuild` directory and a `seeder-deploy.yaml`
41-
```bash
42-
gcloud builds submit \
43-
--project deploy-276111 \
44-
--config .cloudbuild/seeder-deploy.yaml \
45-
--substitutions "_SERVICE=my-quizz:v1,_REGION=europe-west1,_INSTANCE_NAME=my-sql-database,_DATABASE_URL=mysql://my-quizz:password@localhost?unix_socket=/cloudsql/deploy-276111:europe-west1:my-sql-database;dbname=my_quizz"
46-
```
117+
![article](.github/preview/home.png "Home page")
118+
![article](.github/preview/indexquizz.png "Quizz page")
119+
![article](.github/preview/showquizz.png "Play a quiz page")
120+
![article](.github/preview/historyindex.png "History page")
121+
![article](.github/preview/historyshow.png "History of a quiz")
122+
![article](.github/preview/register.png " Register page")
123+
![article](.github/preview/login.png " Login page")
124+
![article](.github/preview/admin.png " Admin page")

src/Controller/EditMailController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public function index(Request $request,MailerInterface $mailer)
4848

4949
// do anything else you need here, like send an email
5050
$email = (new TemplatedEmail())
51-
51+
5252
->to($saveEmail)
53-
->subject('Experimenting with Symfony Mailer and Mailtrap')
53+
->subject('Validation adresse mail')
5454
// path to your Twig template
5555
->htmlTemplate('email/confirmNewEmail.html.twig')
5656
->context([

src/Controller/EditPasswordController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public function index(Request $request, MailerInterface $mailer)
5050

5151
// do anything else you need here, like send an email
5252
$email = (new TemplatedEmail())
53-
53+
5454
->to($this->user->getEmail())
55-
->subject('Experimenting with Symfony Mailer and Mailtrap')
55+
->subject('Validation nouveau mot de passe')
5656
// path to your Twig template
5757
->htmlTemplate('email/confirmEditPassword.html.twig')
5858
->context([

src/Controller/RegistrationController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public function register(Request $request, UserPasswordEncoderInterface $passwor
3838

3939
// do anything else you need here, like send an email
4040
$email = (new TemplatedEmail())
41-
41+
4242
->to($user->getEmail())
43-
->subject('Experimenting with Symfony Mailer and Mailtrap')
43+
->subject('Inscription My Quizz')
4444
// path to your Twig template
4545
->htmlTemplate('email/confirmAccount.html.twig')
4646
->context([

templates/baseEmail.html.twig

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<p><strong>★ My Quizz ★</strong></p>
1+
<h1> ★ My Quizz ★ </h1>
22

33
{% block body %}
44
{% endblock %}
55

6-
<p>Toute l'équipe My Quizz, à bientôt</p>
7-
<img class="logo" src="{{ absolute_url(asset("media/kitten.jpg")) }}" alt="Logo My Quizz">
6+
<p>(^◕ᴥ◕^) Toute l'équipe My Quizz, à bientôt ! </p>
7+
<img class="logo" src="{{ email.image('email/media/kitten.jpg') }}" alt="Logo My Quizz">

templates/email/confirmAccount.html.twig

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
{% block body %}
44
{% set url = url('app_confirmation_email_register', {token: user.confirmationToken, user: user.id}) %}
5-
<h1>Validation de compte</h1>
5+
<h3>Validation de compte</h3>
66

77
<p>Vous recevez cette e-mail, car vous avez créé un compte sur notre site My Quizz !</p>
88
<p>Avant de pouvoir vous connecter et participer à des quiz vous devez valider votre adresse mail</p>
99

1010
<p>Confirmer votre compte : <a href="{{ url }}">{{ url }}</a></p>
11-
1211
{% endblock %}

templates/email/confirmEditPassword.html.twig

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
{% block body %}
44
{% set url = url('confirmed_edit_password', {token: user.confirmationToken, user: user.id, pwd: pwd}) %}
55

6-
<h1>Validation de votre nouveau mot de passe</h1>
6+
<h3>Validation de votre nouveau mot de passe</h3>
77

88
<p>Vous recevez cette e-mail, car vous avez changé votre mot de passe !</p>
99
<p>Nous avons bien pris en compte votre demande, mais avant de pouvoir changer
1010
votre mot de passe de manière définitive vous devez valider votre action. </p>
1111
<p>Si vous n'avez pas demandé le changement de votre mot de passe, merci de ne pas prendre en compte cette e-mail</p>
1212

1313
<p>Confirmer votre nouveau mot de passe : <a href="{{ url }}">{{ url }}</a></p>
14-
1514
{% endblock %}

templates/email/confirmNewEmail.html.twig

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
{% block body %}
44
{% set url = url('app_confirmation_edit_email', {token: user.confirmationToken, user: user.id, mail: mail}) %}
5-
<h1>Vous changez d'adresse e-mail ? </h1>
5+
<h3>Vous changez d'adresse e-mail ? </h3>
66

77
<p>Vous recevez cette e-mail, car vous avez effectué un changement d'adresse e-mail !</p>
88
<p>Nous avons bien pris en compte votre demande, mais avant de pouvoir changer
@@ -11,6 +11,4 @@
1111
<p>Si vous n'avez pas demandé le changement de votre e-mail, merci de ne pas prendre en compte cette e-mail</p>
1212

1313
<p>Confirmer votre nouvelle adresse mail : <a href="{{ url }}">{{ url }}</a></p>
14-
15-
1614
{% endblock %}
File renamed without changes.

0 commit comments

Comments
 (0)