Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature branch: use wouterj/eloquent-bundle #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ APP_SECRET=sFiChPNdQsY9TWJDLMf4FY22tCDfcxxM
# 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"

###> wouterj/eloquent-bundle ###
DB_CONNECTION=sqlite
#DB_HOST=127.0.0.1
#DB_PORT=3306
DB_DATABASE=var/data.db
#DB_USERNAME=root
#DB_PASSWORD=
###< wouterj/eloquent-bundle ###
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ help: ## Outputs this help screen
.PHONY: version-php version-composer version-symfony version-phpunit version-phpstan version-php-cs-fixer check-requirements

# You can modify the coverage threshold here
COVERAGE_THRESHOLD = 100
COVERAGE_THRESHOLD = 80

## —— Symfony binary 💻 ————————————————————————————————————————————————————————
start: ## Serve the application with the Symfony binary
Expand Down Expand Up @@ -36,13 +36,18 @@ warmup: ## Warmup the dev cache for the static analysis
purge: ## Purge all Symfony cache and logs
@rm -rf ./var/cache/* ./var/logs/* ./var/coverage/*

load-fixtures: ## Reset migrations and load the database fixtures
@rm -f ./var/data.db
@touch ./var/data.db
@bin/console eloquent:migrate:fresh --seed


## —— Tests ✅ —————————————————————————————————————————————————————————————————
test: ## Run all PHPUnit tests
test: purge load-fixtures ## Run all PHPUnit tests
@vendor/bin/phpunit

coverage: ## Generate the HTML PHPUnit code coverage report (stored in var/coverage)
coverage: purge
coverage: purge load-fixtures
@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 $(COVERAGE_THRESHOLD)

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ In both cases, your controller code has to be [modified accordingly](https://sym

## References 📚

* [PHPStan 2.0 Released With Level 10 and Elephpants!](https://phpstan.org/blog/phpstan-2-0-released-level-10-elephpants) (phpstan.org)
* [A better ADR pattern for your Symfony controllers](https://www.strangebuzz.com/en/blog/a-better-adr-pattern-for-your-symfony-controllers) (strangebuzz.com)
* [A better ADR pattern for your Symfony controllers](https://www.strangebuzz.com/en/blog/a-better-adr-pattern-for-your-symfony-controllers) (strangebuzz.com) (coming soon)
* [My Taskfile configuration for Symfony](https://jmsche.fr/en/blog/my-taskfile-configuration-for-symfony) (jmsche.fr)
* [You should be using PHPStans bleeding edge](https://backendtea.com/post/use-phpstan-bleeding-edge/) (backendtea.com)
* [A Good Naming Convention for Routes, Controllers and Templates?](https://jolicode.com/blog/a-good-naming-convention-for-routes-controllers-and-templates) (jolicode.com)
Expand Down
15 changes: 14 additions & 1 deletion castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// use function Castor\parallel;

// You can modify the coverage threshold here
const COVERAGE_THRESHOLD = 100;
const COVERAGE_THRESHOLD = 80;

function title(string $name): void
{
Expand Down Expand Up @@ -93,10 +93,21 @@ function purge(): void
success(exit_code('rm -rf ./var/cache/* ./var/logs/* ./var/coverage/*'));
}

#[AsTask(namespace: 'app', description: 'Load the database fixtures', aliases: ['load-fixtures'])]
function loadFixures(): void
{
title('app:load-fixtures');
io()->note('Resetting db...');
success(exit_code('rm -f ./var/data.db && touch ./var/data.db'));
io()->note('Running db migrations and load fixtures...');
success(exit_code('bin/console eloquent:migrate:fresh --seed'));
}

#[AsTask(name: 'all', namespace: 'test', description: 'Run all PHPUnit tests', aliases: ['test'])]
function test_all(): int
{
title('test:all');
loadFixures();
$ec = exit_code(__DIR__.'/vendor/bin/phpunit');
io()->writeln('');

Expand All @@ -107,6 +118,7 @@ function test_all(): int
function coverage(): int
{
title('test:coverage');
loadFixures();
$ec = exit_code('php -d xdebug.enable=1 -d memory_limit=-1 vendor/bin/phpunit --coverage-html=var/coverage --coverage-clover=var/coverage/clover.xml',
context: context()->withEnvironment(['XDEBUG_MODE' => 'coverage'])
);
Expand Down Expand Up @@ -238,6 +250,7 @@ function ci(): void
{
title('ci:all');
purge();
loadFixures();
io()->section('Coverage');
coverage();
io()->section('Codings standards');
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"ext-libxml": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"laravel/serializable-closure": "^1.3",
"league/commonmark": "^2.4",
"symfony/asset": "~7.1.0",
"symfony/asset-mapper": "~7.1.0",
Expand All @@ -44,10 +45,12 @@
"symfony/yaml": "~7.1.0",
"twig/extra-bundle": "^3.0",
"twig/markdown-extra": "^3.7",
"twig/twig": "^3.0"
"twig/twig": "^3.0",
"wouterj/eloquent-bundle": "^2.7"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8",
"fakerphp/faker": "^1.23",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^11.0",
Expand Down
Loading
Loading