Skip to content
Open

V2 #1

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .autoaliases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

DOCKER_COMPOSE_OPTION="-T"
DOCKER_OPTION=""

phpqa() {
docker run $DOCKER_OPTION --rm -v `pwd`/:/project -w /project jakzal/phpqa:php7.4-alpine "$@"
}

composer-unused() {
phpqa composer-unused -vvv
}

phpunit () {
phpqa phpdbg -qrr /tools/phpunit -c . --colors=never --exclude-group excluded,functionnal $@
}

symfony () {
docker run --rm -v $(pwd):$(pwd) -w $(pwd) symfonycorp/cli $@
}

composer () {
docker run --rm -v `pwd`/:/project -w /project jakzal/phpqa:php7.4-alpine composer $@
}

php-cs-fixer() {
phpqa php-cs-fixer fix --using-cache=no --verbose --diff $@
}

php-cs-fixer-fix() {
phpqa php-cs-fixer fix --using-cache=no --verbose $@
}
41 changes: 41 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=74bac029f4a858b72f33ac376fbb58d4
###< symfony/framework-bundle ###

###> symfony/mailer ###
# MAILER_DSN=smtp://localhost
###< symfony/mailer ###

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
DATABASE_URL="mysql://gandalf:frodon@db:3306/mordor?serverVersion=5.7"
# DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
###< 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 ###

APP_MAIL_SENDTO=
7 changes: 7 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
APP_MAIL_SENDTO=
6 changes: 6 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
25 changes: 25 additions & 0 deletions .github/workflows/quality_checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Quality checker

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

quality_checker:

runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Run linter
run: make lint
- name: Run security checker
run: make security
- name: Run cs fixer
run: make php-cs-fixer
- name: Run phpunit
run: make phpunit
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.composer
###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

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

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

# idea files created by Phpstorm
.idea
.idea/*
###> symfony/webpack-encore-bundle ###
/node_modules/
/public/build/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###
54 changes: 54 additions & 0 deletions .hooks/change_detector.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

# @param hook_type post-checkout|post-merge|post-commit|pre-commit
# @param monitored_paths the paths to check
has_changed()
{
local hook_type=$1; shift
local monitored_paths="$@"
local against
local changed
local workDir
set -f

workDir=$(git rev-parse --show-toplevel)

case $hook_type in
post-commit)
if git rev-parse --verify HEAD^ >/dev/null 2>&1
then
against=HEAD^
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
changed="$(git diff-tree $against 'HEAD' \
--stat \
-- ${monitored_paths}| wc -l)"
;;
post-checkout | post-merge )
changed="$(git diff 'HEAD@{1}' \
--stat \
-- ${monitored_paths}| wc -l)"
;;
pre-commit)
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
changed="$(git diff-index \
--name-status $against \
-- ${monitored_paths} | wc -l)"
;;
esac

if [ "$changed" -gt 0 ]
then
return 0
else
return 1
fi
}
6 changes: 6 additions & 0 deletions .hooks/junk-words
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
debugger
var_dump
xdebug_break
dump
console.log
AbstractMigration
15 changes: 15 additions & 0 deletions .hooks/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

GIT_DIR=${GIT_DIR-`git rev-parse --git-dir`}
. "$GIT_DIR/hooks/change_detector.sh"

if [ -f composer.lock ]
then
if has_changed post-checkout composer.lock
then
echo "composer.lock has changed!"
make composer-install
fi
else
echo "no composer.lock found!"
fi
15 changes: 15 additions & 0 deletions .hooks/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

GIT_DIR=${GIT_DIR-`git rev-parse --git-dir`}
. "$GIT_DIR/hooks/change_detector.sh"

if [ -f composer.lock ]
then
if has_changed post-merge composer.lock
then
echo "composer.lock has changed!"
echo "You should run Composer!"
fi
else
echo "no composer.lock found!"
fi
40 changes: 40 additions & 0 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

GIT_DIR=${GIT_DIR-`git rev-parse --git-dir`}
. "$GIT_DIR/hooks/change_detector.sh"

junkchecker_phrases_file="$GIT_DIR/hooks/junk-words"
if [ -f $junkchecker_phrases_file ]
then
for FILE in $(git diff-index --cached --name-status HEAD -- | cut -c 3-); do
if [ -f "$FILE" ]
then
while IFS='' read -r line || [[ -n "$line" ]];
do
git diff --cached --diff-filter=ACMR "$FILE" | grep -E '^\+' | grep --quiet "$line"
if [ $? -eq 0 ]
then
cat <<- EOT >&2
Junk checker detected: $FILE contains '$line'.
Use the --no-verify option to bypass this error message.
EOT
exit 1
fi
done < "$junkchecker_phrases_file"
fi
done
else
echo "Could not find file $junkchecker_phrases_file . Please check your configuration."
exit 2
fi

if has_changed pre-commit composer.json
then
source ./.autoaliases.sh
composer -q validate
isValid=$?
if [ $isValid -ne 0 ]
then
exit $isValid
fi
fi
30 changes: 30 additions & 0 deletions .hooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# execute a command hidden if fail ask if re rerun command with output
#
# sample : run_command make test
#
function run_command {
LAST_CMD=$@
printf "\033[36m running : \033[34m $LAST_CMD \033[0m"
$($LAST_CMD >> /dev/null 2>&1)
rc=$?
if [[ $rc != 0 ]] ; then
printf "\033[31m .. Fail \033[0m\n"
echo -n "Bouh Looser ! "
exit $rc;
else
printf "\033[32m .. PASS \033[0m\n"
fi
}

exec < /dev/tty
make banner
run_command make security
run_command make db-validate-schema
run_command make lp
run_command make ly
run_command make composer-validate
run_command make phpunit

exit 0
70 changes: 70 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# For a symfony application to work properly, you MUST store this .htaccess in
# the same directory as your front controller, index.php, in a standard symfony
# web application is under the "public" project subdirectory.

# Use the front controller as index file.
DirectoryIndex index.php

# Uncomment the following line if you install assets as symlinks or if you
# experience problems related to symlinks when compiling LESS/Sass/CoffeScript.
# Options +FollowSymlinks

# Disabling MultiViews prevents unwanted negotiation, e.g. "/index" should not resolve
# to the front controller "/index.php" but be rewritten to "/index.php/index".
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On

# This RewriteRule is used to dynamically discover the RewriteBase path.
# See https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
# Here we will compare the stripped per-dir path *relative to the filesystem
# path where the .htaccess file is read from* with the URI of the request.
#
# If a match is found, the prefix path is stored into an ENV var that is later
# used to properly prefix the URI of the front controller index.php.
# This is what makes it possible to host a Symfony application under a subpath,
# such as example.com/subpath

# The convoluted rewrite condition means:
# 1. Match all current URI in the RewriteRule and backreference it using $0
# 2. Strip the request uri the per-dir path and use ir as REQUEST_URI.
# This is documented in https://bit.ly/3zDm3SI ("What is matched?")
# 3. Evaluate the RewriteCond, assuming your DocumentRoot is /var/www/html,
# this .htaccess is in the /var/www/html/public dir and your request URI
# is /public/hello/world:
# * strip per-dir prefix: /var/www/html/public/hello/world -> hello/world
# * applying pattern '.*' to uri 'hello/world'
# * RewriteCond: input='/public/hello/world::hello/world' pattern='^(/.+)/(.*)::\\2$' => matched
# 4. Execute the RewriteRule:
# * The %1 in the RewriteRule flag E=BASE:%1 refers to the first group captured in the RewriteCond ^(/.+)/(.*)
# * setting env variable 'BASE' to '/public'
RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
#RewriteRule .* - [E=BASE:%1]
RewriteRule .* - [/public:%1]

# Sets the HTTP_AUTHORIZATION header removed by Apache
RewriteCond %{HTTP:Authorization} .+
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]

# Removes the /index.php/ part from a URL, if present
RewriteCond %{ENV:REDIRECT_STATUS} =""
#RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteRule ^index\.php(?:/(.*)|$) %/public/$1 [R=301,L]

# If the requested filename exists, simply serve it.
# Otherwise rewrite all other queries to the front controller.
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^ %{ENV:BASE}/index.php [L]
RewriteRule ^ %/public/index.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect
# to the front controller explicitly so that the website
RedirectMatch 307 ^/$ /index.php/
</IfModule>
</IfModule>
Loading