Skip to content

Commit

Permalink
base application setup
Browse files Browse the repository at this point in the history
  • Loading branch information
chr-hertel committed Aug 30, 2019
1 parent 7a9d6e4 commit 41f867a
Show file tree
Hide file tree
Showing 19 changed files with 431 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ APP_SECRET=b0795f5bab7f1f59344cd7c85675454a
# Configure your db driver and server_version in config/packages/doctrine.yaml
DATABASE_URL=sqlite:///%kernel.project_dir%/var/data.db
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=null://localhost
###< symfony/swiftmailer-bundle ###
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
DATABASE_URL=sqlite:///%kernel.project_dir%/var/data-test.db
80 changes: 80 additions & 0 deletions Challenges.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Symfony Forms in Detail

Trainer: https://twitter.com/el_stoffel
Repository: https://github.com/chr-hertel/product-crud

## Challenge 1 - Contact Form

* merge branch `contact/01-base`
```bash
$ git merge contact/01-base
```
* implement `App\Contact\Dto`
* see `App\Contact\Mailer` for help
* implement `App\Form\ContactType`
* implement `App\Contact\ContactController::contact(...)`
* URI `/contact`
* route name `contact`
* implement template `templates/contact.html.twig`

See documentation for help:
* https://symfony.com/doc/current/forms.html#usage
* https://symfony.com/doc/current/best_practices/forms.html

### Additional challenges

* Form Validation
```bash
$ git merge contact/02-validation
```
* Form Layout
```bash
$ git merge contact/03-layout
```

## Challenge 2 - Category Form

* merge branch `category/01-base`
```bash
$ git merge category/01-base
```
* update Doctrine schema
```bash
$ bin/console doctrine:schema:update --force
```
* implement `App\Form\CategoryType` using `DataMapper` and `empty_data`
* catch CategoryException and add `FormError` instances

See documentation for help:
* https://symfony.com/doc/current/form/data_mappers.html

### Additional challenges

* optional parent relation
```bash
$ git merge category/02-parent
```
https://symfony.com/doc/current/reference/forms/types/entity.html

* filter parent categories to filter out itself
* use category path as choice label, eg. Food » Vegetable

## Challenge 3 - Product Form

* merge branch `product/01-base`
```bash
$ git merge product/01-base
```
* implement `App\Form\SkuType` using `DataTransformer` and `TextType` as parent
* implement `App\Form\Product` for `App\Entity\Product` using `DataMapper`

See documentation for help:
* https://symfony.com/doc/current/form/data_transformers.html
* https://symfony.com/doc/current/reference/forms/types/entity.html

### Additional challenges

* change view of `sku` to read-only when sku is already set
```bash
$ git merge product/02-view
```
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"symfony/form": "4.3.*",
"symfony/framework-bundle": "4.3.*",
"symfony/monolog-bundle": "^3.4",
"symfony/swiftmailer-bundle": "^3.2",
"symfony/twig-bundle": "4.3.*",
"symfony/validator": "4.3.*",
"symfony/yaml": "4.3.*"
Expand Down
187 changes: 186 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
];
4 changes: 4 additions & 0 deletions config/packages/dev/swiftmailer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See https://symfony.com/doc/current/email/dev_environment.html
swiftmailer:
# send all emails to a specific address
#delivery_addresses: ['me@example.com']
3 changes: 3 additions & 0 deletions config/packages/swiftmailer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
swiftmailer:
url: '%env(MAILER_URL)%'
spool: { type: 'memory' }
2 changes: 2 additions & 0 deletions config/packages/test/swiftmailer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
swiftmailer:
disable_delivery: true
5 changes: 5 additions & 0 deletions config/services_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
_defaults:
public: true

test.Doctrine\ORM\EntityManagerInterface: '@Doctrine\ORM\EntityManagerInterface'
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ parameters:
paths:
- src/
- tests/
autoload_files:
- '%currentWorkingDirectory%/bin/.phpunit/phpunit-7.5/vendor/autoload.php'
inferPrivatePropertyTypeFromConstructor: true
7 changes: 7 additions & 0 deletions public/bootstrap.min.css

Large diffs are not rendered by default.

Binary file added public/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
"config/packages/dev/easy_log_handler.yaml"
]
},
"egulias/email-validator": {
"version": "2.1.11"
},
"friendsofphp/php-cs-fixer": {
"version": "2.2",
"recipe": {
Expand Down Expand Up @@ -192,6 +195,9 @@
"config/packages/security_checker.yaml"
]
},
"swiftmailer/swiftmailer": {
"version": "v6.2.1"
},
"symfony/asset": {
"version": "v4.3.3"
},
Expand Down Expand Up @@ -404,6 +410,20 @@
"symfony/stopwatch": {
"version": "v4.3.3"
},
"symfony/swiftmailer-bundle": {
"version": "2.5",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "2.5",
"ref": "429afc6c6778a1fdddb52a4f708cd94ff2c9960f"
},
"files": [
"config/packages/dev/swiftmailer.yaml",
"config/packages/swiftmailer.yaml",
"config/packages/test/swiftmailer.yaml"
]
},
"symfony/test-pack": {
"version": "v1.0.6"
},
Expand Down
Empty file removed templates/.gitignore
Empty file.
Loading

0 comments on commit 41f867a

Please sign in to comment.