Skip to content

Commit

Permalink
Update Symfony recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Goudriaan authored and codedmonkey committed Jan 10, 2025
1 parent 235ccde commit 52cdefe
Show file tree
Hide file tree
Showing 24 changed files with 197 additions and 114 deletions.
21 changes: 19 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# 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

COMPOSE_PROJECT_NAME=na-website

### Runtime variables
Expand Down Expand Up @@ -43,7 +59,8 @@ APP_SECRET=86e65e43da3975441a202235908a0a52
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
DATABASE_URL="mysql://dudenamedben:dudettenamedbernadette@database:3306/noagenda?serverVersion=8"
# DATABASE_URL="postgresql://symfony:[email protected]:5432/app?serverVersion=13&charset=utf8"
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
# DATABASE_URL="postgresql://app:[email protected]:5432/app?serverVersion=16&charset=utf8"
###< doctrine/doctrine-bundle ###

###> sentry/sentry-symfony ###
Expand All @@ -58,9 +75,9 @@ MAILER_FROM_AUTHOR="No Agenda Website"

###> symfony/messenger ###
# Choose one of the transports below
# MESSENGER_TRANSPORT_DSN=doctrine://default
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
###< symfony/messenger ###

###> symfony/telegram-notifier ###
Expand Down
Empty file added .env.dev
Empty file.
4 changes: 4 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

if (!is_dir(dirname(__DIR__).'/vendor')) {
throw new LogicException('Dependencies are missing. Try running "composer install".');
}

if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}
Expand Down
10 changes: 7 additions & 3 deletions bin/phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ if (!ini_get('date.timezone')) {
}

if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
if (PHP_VERSION_ID >= 80000) {
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
} else {
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
}
} else {
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
Expand Down
10 changes: 9 additions & 1 deletion config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ doctrine:

# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '13'
#server_version: '16'

profiling_collect_backtrace: '%kernel.debug%'
use_savepoints: true
orm:
auto_generate_proxy_classes: true
enable_lazy_ghost_objects: true
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
type: attribute
is_bundle: false
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
Expand All @@ -30,6 +37,7 @@ when@prod: &doctrine_prod
doctrine:
orm:
auto_generate_proxy_classes: false
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
query_cache_driver:
type: pool
pool: doctrine.system_cache_pool
Expand Down
2 changes: 1 addition & 1 deletion config/packages/doctrine_migrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ doctrine_migrations:
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
'DoctrineMigrations': '%kernel.project_dir%/migrations'
enable_profiler: '%kernel.debug%'
enable_profiler: false
3 changes: 2 additions & 1 deletion config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ framework:
secret: '%env(APP_SECRET)%'
#csrf_protection: true
http_cache: true
annotations: false
http_method_override: false
handle_all_throwables: true

trusted_proxies: '%env(string:default::TRUSTED_PROXIES)%'
trusted_headers: ['x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port', 'x-forwarded-prefix']
Expand All @@ -14,7 +16,6 @@ framework:
handler_id: null
cookie_secure: auto
cookie_samesite: lax
storage_factory_id: session.storage.factory.native

#esi: true
#fragments: true
Expand Down
9 changes: 9 additions & 0 deletions config/packages/messenger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ framework:
queue_name: failed
auto_setup: false

# Route your messages to the transports
routing:
'App\Message\Crawl': crawler
'App\Message\PrepareEpisode': crawler
Expand All @@ -45,3 +46,11 @@ framework:
doctrine_close_connection
-
doctrine_transaction

# when@test:
# framework:
# messenger:
# transports:
# # replace with your transport name here (e.g., my_transport: 'in-memory://')
# # For more Messenger testing tools, see https://github.com/zenstruck/messenger-test
# async: 'in-memory://'
5 changes: 3 additions & 2 deletions config/packages/monolog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ when@staging:
deprecation:
type: rotating_file
channels: [deprecation]
path: "%kernel.logs_dir%/deprecation.log"
max_files: 28
path: php://stderr
formatter: monolog.formatter.json

crawler_console:
type: console
channels: [crawler]
Expand Down
2 changes: 2 additions & 0 deletions config/packages/notifier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ framework:
channel_policy:
high: ['chat/notifications']
chatter_transports:
telegram: '%env(TELEGRAM_DSN)%'
notifications: '%env(APP_NOTIFICATIONS_DSN)%'
texter_transports:
1 change: 1 addition & 0 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ security:
ROLE_ADMIN: ROLE_MOD
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: bcrypt

Expand Down
23 changes: 23 additions & 0 deletions config/packages/sentry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,31 @@ parameters:
when@prod: &sentry_prod
sentry:
dsn: '%env(SENTRY_DSN)%'
# this hooks into critical paths of the framework (and vendors) to perform
# automatic instrumentation (there might be some performance penalty)
# https://docs.sentry.io/platforms/php/guides/symfony/performance/instrumentation/automatic-instrumentation/
tracing:
enabled: false
options:
before_send: App\EventListener\Sentry\BeforeSendListener
environment: '%env(string:default:sentry_environment:SENTRY_ENVIRONMENT)%'

# If you are using Monolog, you also need this additional configuration to log the errors correctly:
# https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration
# register_error_listener: false
# register_error_handler: false

# monolog:
# handlers:
# sentry:
# type: sentry
# level: !php/const Monolog\Logger::ERROR
# hub_id: Sentry\State\HubInterface

# Uncomment these lines to register a log message processor that resolves PSR-3 placeholders
# https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration
# services:
# Monolog\Processor\PsrLogMessageProcessor:
# tags: { name: monolog.processor, handler: sentry }

when@staging: *sentry_prod
8 changes: 1 addition & 7 deletions config/packages/translation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,4 @@ framework:
default_path: '%kernel.project_dir%/translations'
fallbacks:
- en
# providers:
# crowdin:
# dsn: '%env(CROWDIN_DSN)%'
# loco:
# dsn: '%env(LOCO_DSN)%'
# lokalise:
# dsn: '%env(LOKALISE_DSN)%'
providers:
1 change: 1 addition & 0 deletions config/packages/twig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ twig:
drebscott_url: 'https://noauthority.social/@drebscott'
sirbemrose_url: 'https://bemrose.social/ryan'
voidzero_url: 'https://podcastindex.social/@voidzero'
file_name_pattern: '*.twig'

when@test:
twig:
Expand Down
4 changes: 3 additions & 1 deletion config/packages/web_profiler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ when@dev:
intercept_redirects: false

framework:
profiler: { only_exceptions: false }
profiler:
only_exceptions: false
collect_serializer_data: true

when@test:
web_profiler:
Expand Down
5 changes: 5 additions & 0 deletions config/packages/webpack_encore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ webpack_encore:
builds:
app: '%kernel.project_dir%/public/build'
console: '%kernel.project_dir%/public/console-build'
# builds:
# frontend: '%kernel.project_dir%/public/frontend/build'

# pass the build name as the 3rd argument to the Twig functions
# {{ encore_entry_script_tags('entry1', null, 'frontend') }}

framework:
assets:
Expand Down
8 changes: 5 additions & 3 deletions config/routes.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#index:
# path: /
# controller: App\Controller\DefaultController::index
controllers:
resource:
path: ../src/Controller/
namespace: App\Controller
type: attribute
7 changes: 0 additions & 7 deletions config/routes/annotations.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions config/routes/security.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_security_logout:
resource: security.route_loader.logout
type: service
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"private": true,
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.17.0",
"@babel/preset-env": "^7.16.0",
"@fortawesome/fontawesome-free": "^6.1.1",
"@hotwired/stimulus": "^3.0.0",
"@octopodcasting/player": "octopodcasting/player#new-dist",
Expand All @@ -28,7 +30,10 @@
"sass": "^1.38.2",
"sass-loader": "^13.3.2",
"srt-parser-2": "^1.1.8",
"swup": "^4.5.0"
"swup": "^4.5.0",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-notifier": "^1.15.0"
},
"scripts": {
"build": "encore dev",
Expand Down
6 changes: 1 addition & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
<server name="SYMFONY_PHPUNIT_VERSION" value="9.5" />
<server name="SYMFONY_PHPUNIT_VERSION" value="9.6" />
</php>

<testsuites>
Expand All @@ -33,10 +33,6 @@
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>

<!-- Run `composer require symfony/panther` before enabling this extension -->
<!--
<extensions>
<extension class="Symfony\Component\Panther\ServerExtension" />
</extensions>
-->
</phpunit>
Loading

0 comments on commit 52cdefe

Please sign in to comment.