generated from strangebuzz/MicroSymfony
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4b82d1c
Showing
79 changed files
with
13,368 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# 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. | ||
# https://symfony.com/doc/current/configuration/secrets.html | ||
# | ||
# 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_DEBUG=1 | ||
APP_SECRET=3bUhVCRkHJfT2ZJTqBnvkclRFT1zy1ig | ||
###< symfony/framework-bundle ### | ||
|
||
# To test the production environment, run "make go-prod" or "castor symfony:go-prod" | ||
|
||
# To come back to the development environment, run "make go-dev" or "castor symfony:go-dev" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
APP_ENV=prod | ||
APP_DEBUG=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: Symfony | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
XDEBUG_MODE: coverage | ||
|
||
jobs: | ||
# Run tests —————————————————————————————————————————————————————————————————— | ||
symfony-tests: | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
php-versions: ['8.2', '8.3'] | ||
runs-on: ubuntu-latest | ||
|
||
# Setup ———————————————————————————————————————————————————————————————— | ||
steps: | ||
- uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
coverage: xdebug | ||
tools: castor | ||
- uses: actions/checkout@v3 | ||
|
||
# Composer ————————————————————————————————————————————————————————————— | ||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: | | ||
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
- uses: actions/cache@v3 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Install Dependencies | ||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | ||
|
||
- name: Audit the code for vulnerabilities | ||
run: composer audit | ||
|
||
# Tests ———————————————————————————————————————————————————————————————— | ||
- name: Execute tests via PHPUnit | ||
run: castor test | ||
|
||
# Code coverage ———————————————————————————————————————————————————————— | ||
- name: Generate the code coverage report and show the current global coverage | ||
run: castor coverage | ||
|
||
|
||
# Run all lint/CS checks ————————————————————————————————————————————————————— | ||
symfony-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Setup ———————————————————————————————————————————————————————————————— | ||
- uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.2' | ||
tools: cs2pr, castor | ||
- uses: actions/checkout@v3 | ||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: | | ||
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
- uses: actions/cache@v3 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Install PHP dependencies | ||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | ||
- name: Install PHPUnit dependencies for PHPStan | ||
run: vendor/bin/phpunit --version | ||
|
||
# Native Symfony lints ————————————————————————————————————————————————— | ||
- name: Lint the DI container | ||
run: castor lint:container | ||
- name: Lint Twig templates | ||
run: castor lint:twig | ||
- name: Lint Yaml files | ||
run: castor lint:yaml | ||
|
||
# Vendors —————————————————————————————————————————————————————————————— | ||
- name: Lint PHP with php-cs-fixer | ||
run: castor lint:php | ||
- name: PHPStan static analysis | ||
run: castor stan | ||
|
||
# The end. 🙃 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
###> bamarni/composer-bin-plugin ### | ||
/vendor-bin/**/vendor/ | ||
###< bamarni/composer-bin-plugin ### | ||
|
||
###> symfony/framework-bundle ### | ||
/.env.local | ||
/.env.local.php | ||
/.env.*.local | ||
/config/secrets/prod/prod.decrypt.private.php | ||
/public/bundles/ | ||
/var/ | ||
/vendor/ | ||
###< symfony/framework-bundle ### | ||
|
||
###> friendsofphp/php-cs-fixer ### | ||
/.php-cs-fixer.php | ||
/.php-cs-fixer.cache | ||
###< friendsofphp/php-cs-fixer ### | ||
|
||
###> jolicode/castor ### | ||
.castor.stub.php | ||
###< jolicode/castor ### | ||
|
||
###> symfony/asset-mapper ### | ||
/public/assets/ | ||
###< symfony/asset-mapper ### | ||
|
||
###> phpunit/phpunit ### | ||
/phpunit.xml | ||
.phpunit.result.cache | ||
.phpunit.cache | ||
###< phpunit/phpunit ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
// @see https://github.com/symfony/symfony/blob/7.1/.php-cs-fixer.dist.php | ||
|
||
declare(strict_types=1); | ||
|
||
use PhpCsFixer\Config; | ||
use PhpCsFixer\Finder; | ||
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; | ||
|
||
// https://cs.symfony.com/doc/config.html#the-simplest-config | ||
$finder = Finder::create() | ||
->in(__DIR__) | ||
->exclude('var') | ||
; | ||
|
||
return (new Config()) | ||
->setRules([ | ||
// taken from the Symfony config // https://github.com/symfony/symfony/blob/7.1/.php-cs-fixer.dist.php | ||
'@Symfony' => true, // https://cs.symfony.com/doc/ruleSets/Symfony.html | ||
'@Symfony:risky' => true, // https://cs.symfony.com/doc/ruleSets/SymfonyRisky.html | ||
'protected_to_private' => false, // https://cs.symfony.com/doc/rules/class_notation/protected_to_private.html | ||
'nullable_type_declaration' => true, // https://cs.symfony.com/doc/rules/language_construct/nullable_type_declaration.html | ||
'trailing_comma_in_multiline' => [ // https://cs.symfony.com/doc/rules/control_structure/trailing_comma_in_multiline.html | ||
'elements' => [ | ||
'arrays', | ||
'match', | ||
'parameters', | ||
], | ||
], | ||
// additional ones | ||
'phpdoc_to_comment' => false, // https://cs.symfony.com/doc/rules/phpdoc/phpdoc_to_comment.html Needed to avoid messing with @var annotations for PHPStan | ||
'yoda_style' => false, // https://cs.symfony.com/doc/rules/control_structure/yoda_style.html | ||
'declare_strict_types' => true, // https://cs.symfony.com/doc/rules/strict/declare_strict_types.html | ||
]) | ||
->setRiskyAllowed(true) | ||
->setFinder($finder) // https://cs.symfony.com/doc/config.html#the-simplest-config | ||
->setCacheFile('.php-cs-fixer.cache') // https://cs.symfony.com/doc/usage.html#caching | ||
->setParallelConfig(ParallelConfigFactory::detect()) // https://cs.symfony.com/doc/usage.html#the-fix-command | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
SHELL = sh | ||
.DEFAULT_GOAL = help | ||
|
||
## —— 🎶 The MicroSymfony Makefile 🎶 —————————————————————————————————————————— | ||
help: ## Outputs this help screen | ||
@grep -E '(^[a-zA-Z0-9_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/' | ||
.PHONY: help start stop go-prod go-dev purge test coverage cov-report stan fix-php lint-php lint-container lint-twig lint-yaml cs lint ci deploy | ||
.PHONY: version-php version-composer version-symfony version-phpunit version-phpstan version-php-cs-fixer check-requirements | ||
|
||
## —— Symfony binary 💻 ———————————————————————————————————————————————————————— | ||
start: ## Serve the application with the Symfony binary | ||
@symfony serve --daemon | ||
|
||
stop: ## Stop the web server | ||
@symfony server:stop | ||
|
||
|
||
## —— Symfony 🎶 —————————————————————————————————————————————————————————————— | ||
go-prod: ## Switch to the production environment | ||
@cp .env.local.dist .env.local | ||
# uncomment this line to optimize the auto-loading of classes in the prod env | ||
#@composer dump-autoload --no-dev --classmap-authoritative | ||
@bin/console asset-map:compile | ||
|
||
go-dev: ## Switch to the development environment | ||
@rm -f .env.local | ||
@rm -rf ./public/assets/* | ||
#@composer dump-autoload | ||
|
||
warmup: ## Warmup the dev cache for the static analysis | ||
@bin/console c:w --env=dev | ||
|
||
purge: ## Purge all Symfony cache and logs | ||
@rm -rf ./var/cache/* ./var/logs/* ./var/coverage/* | ||
|
||
|
||
## —— Tests ✅ ————————————————————————————————————————————————————————————————— | ||
test: ## Run all PHPUnit tests | ||
@vendor/bin/phpunit | ||
|
||
coverage: ## Generate the HTML PHPUnit code coverage report (stored in var/coverage) | ||
coverage: purge | ||
@XDEBUG_MODE=coverage php -d xdebug.enable=1 -d memory_limit=-1 vendor/bin/phpunit --coverage-html=var/coverage --coverage-clover=var/coverage/clover.xml | ||
@php bin/coverage-checker.php var/coverage/clover.xml 100 | ||
|
||
cov-report: var/coverage/index.html ## Open the PHPUnit code coverage report (var/coverage/index.html) | ||
@open var/coverage/index.html | ||
|
||
|
||
## —— Coding standards/lints ✨ ———————————————————————————————————————————————— | ||
stan: var/cache/dev/App_KernelDevDebugContainer.xml ## Run PHPStan | ||
@vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G -vvv | ||
|
||
# PHPStan needs the dev/debug cache | ||
var/cache/dev/App_KernelDevDebugContainer.xml: | ||
APP_DEBUG=1 APP_ENV=DEV bin/console cache:warmup | ||
|
||
fix-php: ## Fix PHP files with php-cs-fixer (ignore PHP 8.2 warning) | ||
@PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix $(PHP_CS_FIXER_ARGS) | ||
|
||
lint-php: ## Lint PHP files with php-cs-fixer (report only) | ||
lint-php: PHP_CS_FIXER_ARGS=--dry-run | ||
lint-php: fix-php | ||
|
||
lint-container: ## Lint the Symfony DI container | ||
@bin/console lint:container | ||
|
||
lint-twig: ## Lint Twig files | ||
@bin/console lint:twig templates/ | ||
|
||
lint-yaml: ## Lint YAML files | ||
@bin/console lint:yaml --parse-tags config/ | ||
|
||
cs: ## Run all CS checks | ||
cs: fix-php stan | ||
|
||
lint: ## Run all lints | ||
lint: lint-php lint-container lint-twig lint-yaml | ||
|
||
ci: ## Run CI locally | ||
ci: coverage warmup cs lint | ||
|
||
|
||
## —— Other tools and helpers 🔨 ——————————————————————————————————————————————— | ||
versions: version-php version-composer version-symfony version-phpunit version-phpstan version-php-cs-fixer ## Output current stack versions | ||
version-php: | ||
@echo '—— PHP ————————————————————————————————————————————————————————————' | ||
@php -v | ||
version-composer: | ||
@echo '\n—— Composer ———————————————————————————————————————————————————————' | ||
@composer --version | ||
version-symfony: | ||
@echo '\n—— Symfony ————————————————————————————————————————————————————————' | ||
@bin/console --version | ||
version-phpunit: | ||
@echo '\n—— PHPUnit ————————————————————————————————————————————————————————' | ||
@vendor/bin/phpunit --version | ||
version-phpstan: | ||
@echo '—— PHPStan ——————————————————————————————————————————————————————————' | ||
@vendor/bin/phpstan --version | ||
version-php-cs-fixer: | ||
@echo '\n—— php-cs-fixer ———————————————————————————————————————————————————' | ||
@vendor/bin/php-cs-fixer --version | ||
@echo | ||
|
||
check-requirements: ## Checks requirements for running Symfony | ||
@vendor/bin/requirements-checker | ||
|
||
|
||
## —— Deploy & Prod 🚀 ————————————————————————————————————————————————————————— | ||
deploy: ## Simple manual deploy on VPS (this is to update the demo site https://microsymfony.ovh/) | ||
@git pull | ||
@composer install | ||
@chown -R www-data: var/* | ||
@cp .env.local.dist .env.local | ||
@composer dump-env prod | ||
@bin/console asset-map:compile |
Oops, something went wrong.