From fc23008e5733b15629573b75d5d38618fdeb4d1a Mon Sep 17 00:00:00 2001 From: darkelfe14728 Date: Sun, 5 Jul 2020 17:42:57 +0200 Subject: [PATCH] Symfony 5.1 --- .env | 4 +- bin/console | 7 +- config/packages/framework.yaml | 1 + config/packages/prod/monolog.yaml | 9 +- config/packages/routing.yaml | 4 + config/packages/security.yaml | 38 ++-- config/routes.yaml | 11 +- config/routes/annotations.yaml | 9 +- config/services.yaml | 1 - phpunit.xml.dist | 2 +- public/.htaccess | 312 +----------------------------- public/index.php | 9 +- src/Kernel.php | 54 ++---- symfony.lock | 192 +++++++++--------- 14 files changed, 159 insertions(+), 494 deletions(-) diff --git a/.env b/.env index 85a5165..740b95e 100644 --- a/.env +++ b/.env @@ -2,5 +2,7 @@ ###> symfony/framework-bundle ### APP_ENV=dev -APP_SECRET=02d2777e0242595653c8a47180aeba9e +APP_SECRET=47e0bab7bbf4f8507e1c45bba3e891dd +#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 +#TRUSTED_HOSTS='^(localhost|example\.com)$' ###< symfony/framework-bundle ### diff --git a/bin/console b/bin/console index 5de0e1c..8fe9d49 100755 --- a/bin/console +++ b/bin/console @@ -4,6 +4,7 @@ use App\Kernel; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\ArgvInput; +use Symfony\Component\Dotenv\Dotenv; use Symfony\Component\ErrorHandler\Debug; if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { @@ -14,8 +15,8 @@ set_time_limit(0); require dirname(__DIR__).'/vendor/autoload.php'; -if (!class_exists(Application::class)) { - throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.'); +if (!class_exists(Application::class) || !class_exists(Dotenv::class)) { + throw new LogicException('You need to add "symfony/framework-bundle" and "symfony/dotenv" as Composer dependencies.'); } $input = new ArgvInput(); @@ -27,7 +28,7 @@ if ($input->hasParameterOption('--no-debug', true)) { putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); } -require dirname(__DIR__).'/config/bootstrap.php'; +(new Dotenv())->bootEnv(dirname(__DIR__).'/.env'); if ($_SERVER['APP_DEBUG']) { umask(0000); diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index 6089f4b..cad7f78 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -1,3 +1,4 @@ +# see https://symfony.com/doc/current/reference/configuration/framework.html framework: secret: '%env(APP_SECRET)%' #csrf_protection: true diff --git a/config/packages/prod/monolog.yaml b/config/packages/prod/monolog.yaml index 5bcdf06..bfe69c0 100644 --- a/config/packages/prod/monolog.yaml +++ b/config/packages/prod/monolog.yaml @@ -5,6 +5,7 @@ monolog: action_level: error handler: nested excluded_http_codes: [404, 405] + buffer_size: 50 # How many messages should be saved? Prevent memory leaks nested: type: stream path: "%kernel.logs_dir%/%kernel.environment%.log" @@ -13,11 +14,3 @@ monolog: type: console process_psr_3_messages: false channels: ["!event", "!doctrine"] - deprecation: - type: stream - path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log" - deprecation_filter: - type: filter - handler: deprecation - max_level: info - channels: ["php"] diff --git a/config/packages/routing.yaml b/config/packages/routing.yaml index 7e97762..b45c1ce 100644 --- a/config/packages/routing.yaml +++ b/config/packages/routing.yaml @@ -1,3 +1,7 @@ framework: router: utf8: true + + # Configure how to generate URLs in non-HTTP contexts, such as CLI commands. + # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands + #default_uri: http://localhost diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 8291375..0e4cf3d 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -1,30 +1,24 @@ security: - encoders: - App\Entity\User: - algorithm: auto + # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers providers: - app_user_provider: - entity: - class: App\Entity\User - property: email + users_in_memory: { memory: null } firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false main: - anonymous: lazy - remember_me: - secret: '%kernel.secret%' - lifetime: 604800 # 1 week - path: / - secure: true - guard: - authenticators: - - App\Security\LoginFormAuthenticator - logout: - path: app_security_logout - target: app_site_index + anonymous: true + lazy: true + provider: users_in_memory + + # activate different ways to authenticate + # https://symfony.com/doc/current/security.html#firewalls-authentication + + # https://symfony.com/doc/current/security/impersonating_user.html + # switch_user: true + + # Easy way to control access for large sections of your site + # Note: Only the *first* access control that matches will be used access_control: - - { path: ^/sign-in$, roles: IS_AUTHENTICATED_ANONYMOUSLY } - role_hierarchy: - ROLE_ADMIN: ROLE_USER + # - { path: ^/admin, roles: ROLE_ADMIN } + # - { path: ^/profile, roles: ROLE_USER } diff --git a/config/routes.yaml b/config/routes.yaml index 559eb0a..c3283aa 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -1,8 +1,3 @@ -# Redirige l'URL racine vers celle de la langue par défaut -index: - path: / - controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController - defaults: - route: 'app_site_index' - _locale: '%kernel.default_locale%' - permanent: true \ No newline at end of file +#index: +# path: / +# controller: App\Controller\DefaultController::index diff --git a/config/routes/annotations.yaml b/config/routes/annotations.yaml index ff48c7d..e92efc5 100644 --- a/config/routes/annotations.yaml +++ b/config/routes/annotations.yaml @@ -1,8 +1,7 @@ controllers: resource: ../../src/Controller/ type: annotation - prefix: /{_locale} - requirements: - _locale: '%app.supported_locales%' - defaults: - _locale: '%kernel.default_locale%' + +kernel: + resource: ../../src/Kernel.php + type: annotation diff --git a/config/services.yaml b/config/services.yaml index 611d2ff..5c4b417 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -4,7 +4,6 @@ # Put parameters here that don't need to change on each machine where the app is deployed # https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration parameters: - app.supported_locales: 'fr|en' services: # default configuration for services in *this* file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7ad8363..d81f0c3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,7 +5,7 @@ xsi:noNamespaceSchemaLocation="bin/.phpunit/phpunit.xsd" backupGlobals="false" colors="true" - bootstrap="config/bootstrap.php" + bootstrap="tests/bootstrap.php" > diff --git a/public/.htaccess b/public/.htaccess index 33b5e42..2776637 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -1,311 +1,3 @@ -# Apache configuration file - -# ---------------------------------------------------------------------- -# Better website experience for IE users -# ---------------------------------------------------------------------- - -# Force the latest IE version, in various cases when it may fall back to IE7 mode -# github.com/rails/rails/commit/123eb25#commitcomment-118920 -# Use ChromeFrame if it's installed for a better experience for the poor IE folk - - Header set X-UA-Compatible "IE=Edge,chrome=1" - # mod_headers can't match by content-type, but we don't want to send this header on *everything*... - - Header unset X-UA-Compatible - - - -# ---------------------------------------------------------------------- -# Cross-domain AJAX requests -# ---------------------------------------------------------------------- -# Serve cross-domain Ajax requests, disabled by default. -# enable-cors.org -# code.google.com/p/html5security/wiki/CrossOriginRequestSecurity - -# -# Header set Access-Control-Allow-Origin "*" -# - -# ---------------------------------------------------------------------- -# CORS-enabled images (@crossorigin) -# ---------------------------------------------------------------------- -# Send CORS headers if browsers request them; enabled by default for images. -# developer.mozilla.org/en/CORS_Enabled_Image -# blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html -# hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/ -# wiki.mozilla.org/Security/Reviews/crossoriginAttribute - - - - # mod_headers, y u no match by Content-Type?! - - SetEnvIf Origin ":" IS_CORS - Header set Access-Control-Allow-Origin "*" env=IS_CORS - - - - -# ---------------------------------------------------------------------- -# Webfont access -# ---------------------------------------------------------------------- - -# Allow access from all domains for webfonts. -# Alternatively you could only whitelist your -# subdomains like "subdomain.example.com". - - - - Header set Access-Control-Allow-Origin "*" - - - - - -# ---------------------------------------------------------------------- -# Proper MIME type for all files -# ---------------------------------------------------------------------- - -# JavaScript -# Normalize to standard type (it's sniffed in IE anyways) -# tools.ietf.org/html/rfc4329#section-7.2 -AddType application/javascript js - -# Audio -AddType audio/ogg oga ogg -AddType audio/mp4 m4a - -# Video -AddType video/ogg ogv -AddType video/mp4 mp4 m4v -AddType video/webm webm - -# SVG -# Required for svg webfonts on iPad -# twitter.com/FontSquirrel/status/14855840545 -AddType image/svg+xml svg svgz -AddEncoding gzip svgz - -# Webfonts -AddType application/vnd.ms-fontobject eot -AddType application/x-font-ttf ttf ttc -AddType font/opentype otf -AddType application/x-font-woff woff - -# Assorted types -AddType image/x-icon ico -AddType image/webp webp -AddType text/cache-manifest appcache manifest -AddType text/x-component htc -AddType application/x-chrome-extension crx -AddType application/x-opera-extension oex -AddType application/x-xpinstall xpi -AddType application/octet-stream safariextz -AddType application/x-web-app-manifest+json webapp -AddType text/x-vcard vcf - - - -# ---------------------------------------------------------------------- -# Gzip compression -# ---------------------------------------------------------------------- - - - # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/ - - - SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding - RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding - - - - # HTML, TXT, CSS, JavaScript, JSON, XML, HTC: - - - = 2.4> - FilterDeclare COMPRESS - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/html'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/css'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/plain'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/xml'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/x-component'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/javascript'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/json'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/xml'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/xhtml+xml'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/rss+xml'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/atom+xml'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/vnd.ms-fontobject'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'image/svg+xml'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'image/x-icon'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/x-font-ttf'" - FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'font/opentype'" - FilterChain COMPRESS - FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no - - - FilterDeclare COMPRESS - FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html - FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css - FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain - FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml - FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component - FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript - FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json - FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml - FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml - FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml - FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml - FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject - FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml - FilterProvider COMPRESS DEFLATE resp=Content-Type $image/x-icon - FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf - FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype - FilterChain COMPRESS - FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no - - - - - - - # Legacy versions of Apache - AddOutputFilterByType DEFLATE text/html text/plain text/css application/json - AddOutputFilterByType DEFLATE application/javascript - AddOutputFilterByType DEFLATE text/xml application/xml text/x-component - AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml - AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype - - - - - -# ---------------------------------------------------------------------- -# Expires headers (for better cache control) -# ---------------------------------------------------------------------- - -# These are pretty far-future expires headers. -# They assume you control versioning with cachebusting query params like -#