Skip to content

Commit

Permalink
init v1
Browse files Browse the repository at this point in the history
  • Loading branch information
ganti committed Oct 16, 2022
0 parents commit 9c4a2f2
Show file tree
Hide file tree
Showing 163 changed files with 21,279 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
Binary file added .github/img/2fa_setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/email.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/light_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/login_forms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/logs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/org/03_dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/org/04_user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/org/05_2fa_setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/org/05_2fa_user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/org/06_logs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/org/light_dark/dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/org/light_dark/light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/org/light_dark/light_dark.xcf
Binary file not shown.
Binary file added .github/img/org/login_forms/01_login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/org/login_forms/01_register.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/org/login_forms/02_2falogin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/org/login_forms/login_forms.xcf
Binary file not shown.
Empty file added .github/issue_template.md
Empty file.
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Closes #XXXX <- add related issue number here

Effect of the changes:

What was done:

Todos until this is ready for merging:

What was not done on purpose:

How to test the changes:
91 changes: 91 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

.DS_Store
app/vendor/*
app/.env


###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###


# Created by https://www.toptal.com/developers/gitignore/api/symfony
# Edit at https://www.toptal.com/developers/gitignore?templates=symfony

### Symfony ###
# Cache and logs (Symfony2)
/app/cache/*
/app/logs/*
!app/cache/.gitkeep
!app/logs/.gitkeep

# Email spool folder
/app/spool/*

# Cache, session files and logs (Symfony3)
/var/cache/*
/var/logs/*
/var/sessions/*
!var/cache/.gitkeep
!var/logs/.gitkeep
!var/sessions/.gitkeep

# Logs (Symfony4)
/var/log/*
!var/log/.gitkeep

# Parameters
/app/config/parameters.yml
/app/config/parameters.ini

# Managed by Composer
/app/bootstrap.php.cache
/var/bootstrap.php.cache
/bin/*
!bin/console
!bin/symfony_requirements
/vendor/

# Assets and user uploads
/web/bundles/
/web/uploads/

# PHPUnit
/app/phpunit.xml
/phpunit.xml

# Build data
/build/

# Composer PHAR
/composer.phar

# Backup entities generated with doctrine:generate:entities command
**/Entity/*~

# Embedded web-server pid file
/.web-server-pid

### Symfony Patch ###
/web/css/
/web/js/

# End of https://www.toptal.com/developers/gitignore/api/symfony
tools/php-cs-fixer/vendor/
.php-cs-fixer.cache
168 changes: 168 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#!/usr/bin/make -f

ENV = dev
ifdef env
ENV = $(env)
endif


LOCALTEST = false
ifdef localtest
LOCALTEST = $(localtest)
endif

DOCKER_COMPOSE_FILE ?= docker-compose.yml
DOCKER_CONTAINER_PHP = symfony6app-php


DOCKER_CMD = docker exec -t ${DOCKER_CONTAINER_PHP} sh -c

PHP_CMD = ${DOCKER_CMD} 'php
COMPOSER_CMD = ${DOCKER_CMD} 'php -d memory_limit=-1 /usr/bin/composer
SYMFONY_CMD = ${PHP_CMD} bin/console --env=${ENV}
END = '

ifeq ($(ENV),prod)
SYMFONY_CMD += --no-debug
endif


# Docker
inside:
make docker-into-php
docker-into-php:
docker exec -it ${DOCKER_CONTAINER_PHP} bash

docker-rebuild:
docker-compose -f ${DOCKER_COMPOSE_FILE} up -d --force-recreate --build


# Composer
# Example: make composer command="update nothing"
COMPOSER_COMMAND =
ifdef command
COMPOSER_COMMAND = $(command)
endif

composer:
${COMPOSER_CMD} ${COMPOSER_COMMAND} ${END}

composer-install:
${COMPOSER_CMD} install ${END}
make cs-install

dependencies-update:
${COMPOSER_CMD} update --with-all-dependencies ${END}

# Symfony
# Example: make symfony command=about
SYMFONY_COMMAND =
ifdef command
SYMFONY_COMMAND = $(command)
endif

symfony:
${SYMFONY_CMD} ${SYMFONY_COMMAND} ${END}

setup-app:
cp app/.env.dev app/.env
make composer-install
make db-reset || true
make db-migrations
make db-fixtures
make clear-cache
make file-permissions

setup-app-test:
cp app/.env.test app/.env
make db-drop
make db-create
make db-migrations
${SYMFONY_CMD} doctrine:fixtures:load --group=test -n --env=${ENV} ${END}
make db-migrations
make clear-cache
make file-permissions


clear:
rm -rf app/cache/${env}/*
rm -rf app/logs/${env}/*
${SYMFONY_CMD} cache:warmup ${END}

clear-all:
rm -rf app/cache/*
rm -rf app/logs/*
mkdir app/cache/
mkdir app/logs/

clear-cache:
${SYMFONY_CMD} cache:clear ${END}
${SYMFONY_CMD} cache:warmup ${END}

file-permissions:
${DOCKER_CMD} 'chown -R www-data app/cache/ app/logs/ var/' || true


# Database
db-create:
${SYMFONY_CMD} doctrine:schema:create -e ${ENV} ${END}

db-drop:
ifeq ($(ENV),prod)
@echo "Dropping DB on production is disabled"
else
${SYMFONY_CMD} doctrine:schema:drop --force --full-database --env=${ENV} ${END}
endif

db-reset:
ifeq ($(ENV),prod)
@echo "Dropping DB on production is disabled"
else
make db-drop
make db-create
make db-migrations
${SYMFONY_CMD} doctrine:fixtures:load --group=setup -n --env=${ENV} ${END}
endif

db-make-migration:
${SYMFONY_CMD} make:migration ${END}

db-migrations:
${SYMFONY_CMD} doctrine:migrations:migrate --em default --no-interaction ${END}

db-fixtures:
${SYMFONY_CMD} doctrine:fixtures:load -n -e ${ENV} ${END}



# Codestyle
cs-install:
cd tools/php-cs-fixer; composer install

cs-check:
tools/php-cs-fixer/vendor/bin/php-cs-fixer --no-interaction --dry-run --diff -v fix app/src

cs-fix:
tools/php-cs-fixer/vendor/bin/php-cs-fixer --diff -v fix app/src


# translations

trans-extract:
${SYMFONY_CMD} translation:extract --force --format=yaml --as-tree=10 --domain=admin en ${END}
${SYMFONY_CMD} translation:extract --force --format=yaml --as-tree=10 --domain=core en ${END}
${SYMFONY_CMD} translation:extract --force --format=yaml --as-tree=10 --domain=messages en ${END}

#phpunit

tests:
make setup-app-test ENV=test
make tests-phpunit ENV=test

tests-phpunit: clear-cache tests-phpunit-tests

tests-phpunit-tests:
${PHP_CMD} vendor/bin/phpunit --testdox ${PHPUNIT_FILTER} ${END}

testdev:
${PHP_CMD} vendor/bin/phpunit --testdox --group dev ${PHPUNIT_FILTER} ${END}
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Symfony6 Stack

This stack contains some essentials to quick start your symfony project:

- **Docker**: dockerized development environment
- **Authentication**: [Registration](https://symfonycasts.com/screencast/symfony-security/registration-auth), [Email verfication](https://symfonycasts.com/screencast/symfony-security/verify-email), [Password Reset](https://symfonycasts.com/screencast/symfony-security/verify-email), [two-factor authentication (2FA)](https://symfony.com/bundles/SchebTwoFactorBundle/6.x/index.html) with BackupCodes, TrustedDevice
- **EasyAdmin 4.0**: [EasyAdmin](https://github.com/EasyCorp/EasyAdminBundle) is a fast, beautiful and modern admin generator for Symfony applications.
- **Email Templates**: most used elements (header, footer, button) in separated files for an easy include
- **Multiple Languages**: the core features are in translation fiels, easy implementation of other languages
- **API Plattform**: The [API Platform](https://api-platform.com/) with token authentication is ready to use.
- **Traits**: [Reusable Entityfields](https://github.com/ganti/symfony6-stack/tree/main/app/src/Entity/Traits): createdAt, updatedAt, deletedAt (softdelete), isActive, UUID
- **Database Logging**: Most critical and technical issues shall be logged into files, but some user actions may be logged into the database. A simple [Logging engine](https://github.com/ganti/symfony6-stack/blob/main/app/.env.dev) is used to log events into the database
- **PHP Coding Standards Fixer**: normalize your PHP code with [CS-fixer](https://cs.symfony.com/)



<table>
<tr>
<td colspan=2>
<img src="/.github/img/login_forms.png?" alt="Ready to use Forms (Registration, mail verification, Login, 2FA, password reset"><br>
<img src="/.github/img/logs.png" alt="simple user event logging">
</td>
</tr>
<tr>
<td valign="top">
<img src="/.github/img/2fa_setup.png" alt="two setup autentication setup">
<img src="/.github/img/light_dark.png" alt="Easyadmin with light and dark mode">
</td>
<td valign="top" width=50%>
<img src="/.github/img/email.png" alt="Structured emailtemplate">
</td>
</tr>
</table>


## Installation

```bash
sudo docker-compose up -d
make setup-app
```

Browse to [localhost:8001/login](http://localhost:8001/login) and use admin:admin as credentials. Do not forget to change the password!

### Main configuration points
- **app/.env.dev**/**app/.env.prod**: DATABASE_URL, MAILER_DSN
- **app/config/packages/parameters.yaml**: App configuration (Locale, Timezone, Mailer settings)
- **app/config/packages/scheb_2fa.yaml**: two factor configuration (backupcodes, trusted devices)
- **app/config/*.yaml**: many other settings


### Makefile
Here are a few make commands

- `make setup-app`: Setup
- `make inside` jump inside php-container
- `make db-reset`: Reset DB in development (mostly used after changing an entity, but no new migration is created
- `make cs-check` displays what cs fixes are executed when using `make cs-fix`
- `make symfony command="make:entity"` execute symfony console commands with make
- `make composer command="require foobar"` executed composer commands with make

Loading

0 comments on commit 9c4a2f2

Please sign in to comment.