Removed uneeded packages. Upgraded symfony to version 6. Added docker as a way to execute the web application.

This commit is contained in:
theUniC
2022-03-08 23:57:22 +01:00
parent 7e54d73b44
commit e22de1218f
16 changed files with 1945 additions and 2324 deletions

14
.docker/php/Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
FROM php:8.1-apache
ENV APACHE_DOCUMENT_ROOT /var/www/html/public
RUN apt-get update \
&& apt-get -y install librabbitmq-dev \
$PHPIZE_DEPS \
&& docker-php-ext-install pdo_mysql mysqli pcntl \
&& pecl install redis \
&& pecl install amqp \
&& docker-php-ext-enable redis amqp \
&& sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf \
&& sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf \
&& a2enmod rewrite

7
.env
View File

@@ -44,13 +44,6 @@ MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
# passwords that contain special characters (@, %, :, +) must be urlencoded
REDIS_URL=redis://localhost
###< snc/redis-bundle ###
###> lexik/jwt-authentication-bundle ###
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
JWT_PASSPHRASE=925560e7309bd007e6827b45c2ff3166
###< lexik/jwt-authentication-bundle ###
###> app ###
ELASTICSEARCH_DSNS=127.0.0.1:9200
###< app ###

View File

@@ -41,11 +41,10 @@ MESSENGER_TRANSPORT_BASE_DSN=amqp://guest:guest@rabbitmq:5672/%2f
MESSENGER_TRANSPORT_DSN=amqp://guest:guest@rabbitmq:5672/%2f/messages
###< symfony/messenger ###
###> lexik/jwt-authentication-bundle ###
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
JWT_PASSPHRASE=925560e7309bd007e6827b45c2ff3166
###< lexik/jwt-authentication-bundle ###
###> snc/redis-bundle ###
# passwords that contain special characters (@, %, :, +) must be urlencoded
REDIS_URL=redis://redis
###< snc/redis-bundle ###
###> app ###
ELASTICSEARCH_DSNS=elasticsearch:9200

5
.gitignore vendored
View File

@@ -19,11 +19,6 @@ infection.log
###> php-cs-fixer ###
.php-cs-fixer.cache
###< php-cs-fixer ###
###> lexik/jwt-authentication-bundle ###
/config/jwt/*.pem
###< lexik/jwt-authentication-bundle ###
###> yarn ###
.yarn/*
!.yarn/cache

View File

@@ -2,7 +2,7 @@
"type": "project",
"license": "proprietary",
"require": {
"php": ">=8.0",
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"ext-json": "*",
@@ -13,33 +13,33 @@
"doctrine/doctrine-bundle": "^2.4",
"doctrine/doctrine-migrations-bundle": "^3.1",
"doctrine/orm": "^2.9",
"gesdinet/jwt-refresh-token-bundle": "dev-master",
"lexik/jwt-authentication-bundle": "^2.13",
"lstrojny/functional-php": "^1.11",
"nelmio/cors-bundle": "^2.0",
"ramsey/uuid": "^4.0",
"ramsey/uuid-doctrine": "^1.6",
"snc/redis-bundle": "^4.0",
"symfony/asset": "5.3.*",
"symfony/console": "5.3.*",
"symfony/dotenv": "5.3.*",
"symfony/expression-language": "5.3.*",
"symfony/apache-pack": "^1.0",
"symfony/asset": "6.0.*",
"symfony/console": "6.0.*",
"symfony/dotenv": "6.0.*",
"symfony/expression-language": "6.0.*",
"symfony/flex": "^2",
"symfony/framework-bundle": "5.3.*",
"symfony/http-client": "5.3.*",
"symfony/messenger": "5.3.*",
"symfony/process": "5.3.*",
"symfony/proxy-manager-bridge": "5.3.*",
"symfony/runtime": "5.3.*",
"symfony/security-bundle": "5.3.*",
"symfony/twig-bundle": "5.3.*",
"symfony/uid": "5.3.*",
"symfony/validator": "5.3.*",
"symfony/yaml": "5.3.*",
"symfony/framework-bundle": "6.0.*",
"symfony/http-client": "6.0.*",
"symfony/messenger": "6.0.*",
"symfony/process": "6.0.*",
"symfony/proxy-manager-bridge": "6.0.*",
"symfony/runtime": "6.0.*",
"symfony/security-bundle": "6.0.*",
"symfony/twig-bundle": "6.0.*",
"symfony/uid": "6.0.*",
"symfony/validator": "6.0.*",
"symfony/yaml": "6.0.*",
"thecodingmachine/safe": "^1.3",
"webonyx/graphql-php": "^14.4"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"dama/doctrine-test-bundle": "^6.3",
"dg/bypass-finals": "^1.3",
"doctrine/doctrine-fixtures-bundle": "^3.3",
@@ -48,12 +48,12 @@
"keyvanakbary/mimic": "^1.0",
"mockery/mockery": "^1.5",
"phpunit/phpunit": "^9.0",
"symfony/browser-kit": "5.3.*",
"symfony/debug-bundle": "^5.3",
"symfony/browser-kit": "6.0.*",
"symfony/debug-bundle": "6.0.*",
"symfony/maker-bundle": "^1.14",
"symfony/monolog-bundle": "^3.0",
"symfony/stopwatch": "^5.3",
"symfony/web-profiler-bundle": "^5.3",
"symfony/stopwatch": "6.0.*",
"symfony/web-profiler-bundle": "6.0.*",
"theofidry/psysh-bundle": "^4.3"
},
"config": {
@@ -114,7 +114,7 @@
"extra": {
"symfony": {
"allow-contrib": true,
"require": "5.3.*"
"require": "6.0.*"
},
"src-dir": "src/App"
}

3977
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -16,6 +16,4 @@ return [
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
Snc\RedisBundle\SncRedisBundle::class => ['all' => true],
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
Gesdinet\JWTRefreshTokenBundle\GesdinetJWTRefreshTokenBundle::class => ['all' => true],
];

View File

@@ -1,4 +0,0 @@
lexik_jwt_authentication:
secret_key: '%env(resolve:JWT_SECRET_KEY)%'
public_key: '%env(resolve:JWT_PUBLIC_KEY)%'
pass_phrase: '%env(JWT_PASSPHRASE)%'

View File

@@ -1,53 +1,22 @@
security:
enable_authenticator_manager: true
password_hashers:
App\Entity\User:
algorithm: auto
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
# used to reload user from session & other features (e.g. switch_user)
app_user_provider:
entity:
class: App\Entity\User
property: email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
lazy: true
provider: app_user_provider
# 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
api_token_refresh:
pattern: ^/api/token/refresh
stateless: true
refresh_jwt: ~
login:
pattern: ^/api/login
stateless: true
json_login:
check_path: /api/login/check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
api:
pattern: ^/api
stateless: true
jwt: ~
# 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: ^/admin, roles: ROLE_ADMIN }
# - { path: ^/profile, roles: ROLE_USER }
- { path: ^/api/login, roles: PUBLIC_ACCESS }
- { path: ^/api/token/refresh, roles: PUBLIC_ACCESS }
- { path: ^/api/docs, roles: PUBLIC_ACCESS }
- { path: ^/api/users, roles: PUBLIC_ACCESS }
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }

View File

@@ -1,2 +0,0 @@
gesdinet_jwt_refresh_token:
path: /api/token/refresh

View File

@@ -1,2 +0,0 @@
api_login_check:
path: /api/login/check

View File

@@ -15,7 +15,6 @@ services:
Symfony\Component\Messenger\MessageBusInterface $eventBus: "@event.bus"
Symfony\Component\Messenger\MessageBusInterface $projectionBus: "@projection.bus"
Architecture\CQRS\App\Repository\FollowersRepository: '@Architecture\CQRS\Infrastructure\Persistence\Doctrine\DoctrineFollowersRepository'
Redis: '@snc_redis.default'
# makes classes in src/ available to be used as services

View File

@@ -19,3 +19,10 @@ services:
MYSQL_USER: user
MYSQL_PASSWORD: pass
MYSQL_DATABASE: db
app:
build: .docker/php
env_file: .env.docker.dist
ports:
- "8000:80"
volumes:
- ./:/var/www/html

66
public/.htaccess Normal file
View File

@@ -0,0 +1,66 @@
# Use the front controller as index file. It serves as a fallback solution when
# every other rewrite/redirect fails (e.g. in an aliased environment without
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex index.php
# By default, Apache does not evaluate symbolic links if you did not enable this
# feature in your server configuration. Uncomment the following line if you
# install assets as symlinks or if you experience problems related to symlinks
# when compiling LESS/Sass/CoffeScript assets.
# 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
# Determine the RewriteBase automatically and set it as environment variable.
# If you are using Apache aliases to do mass virtual hosting or installed the
# project in a subdirectory, the base path will be prepended to allow proper
# resolution of the index.php file and to redirect to the correct URI. It will
# work in environments without path prefix as well, providing a safe, one-size
# fits all solution. But as you do not need it in this case, you can comment
# the following 2 lines to eliminate the overhead.
RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
RewriteRule .* - [E=BASE:%1]
# Sets the HTTP_AUTHORIZATION header removed by Apache
RewriteCond %{HTTP:Authorization} .+
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
# Redirect to URI without front controller to prevent duplicate content
# (with and without `/index.php`). Only do this redirect on the initial
# rewrite by Apache and not on subsequent cycles. Otherwise we would get an
# endless redirect loop (request -> rewrite to front controller ->
# redirect -> request -> ...).
# So in case you get a "too many redirects" error or you always get redirected
# to the start page because your Apache does not expose the REDIRECT_STATUS
# environment variable, you have 2 choices:
# - disable this feature by commenting the following 2 lines or
# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
# following RewriteCond (best solution)
RewriteCond %{ENV:REDIRECT_STATUS} =""
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
# If the requested filename exists, simply serve it.
# We only want to let Apache serve files and not directories.
# Rewrite all other queries to the front controller.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect of
# the start page to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 307 ^/$ /index.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>

View File

@@ -12,19 +12,4 @@ use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
final class Kernel extends BaseKernel
{
use MicroKernelTrait;
protected function configureContainer(ContainerConfigurator $container): void
{
$container->import('../../config/{packages}/*.yaml');
$container->import('../../config/{packages}/'.$this->environment.'/*.yaml');
$container->import('../../config/{services}.yaml');
$container->import('../../config/{services}_'.$this->environment.'.yaml');
}
protected function configureRoutes(RoutingConfigurator $routes): void
{
$routes->import('../../config/{routes}/'.$this->environment.'/*.yaml');
$routes->import('../../config/{routes}/*.yaml');
$routes->import('../../config/{routes}.yaml');
}
}

View File

@@ -146,12 +146,6 @@
"friendsofphp/proxy-manager-lts": {
"version": "v1.0.5"
},
"fzaninotto/faker": {
"version": "v1.9.1"
},
"gesdinet/jwt-refresh-token-bundle": {
"version": "v0.12.0"
},
"hamcrest/hamcrest-php": {
"version": "v2.0.1"
},
@@ -161,30 +155,6 @@
"laminas/laminas-code": {
"version": "3.4.1"
},
"laminas/laminas-eventmanager": {
"version": "3.2.1"
},
"laminas/laminas-zendframework-bridge": {
"version": "1.0.1"
},
"lcobucci/clock": {
"version": "2.0.0"
},
"lcobucci/jwt": {
"version": "4.1.4"
},
"lexik/jwt-authentication-bundle": {
"version": "2.5",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "2.5",
"ref": "5b2157bcd5778166a5696e42f552ad36529a07a6"
},
"files": [
"config/packages/lexik_jwt_authentication.yaml"
]
},
"lstrojny/functional-php": {
"version": "1.11.0"
},
@@ -197,9 +167,6 @@
"myclabs/deep-copy": {
"version": "1.9.5"
},
"namshi/jose": {
"version": "7.2.3"
},
"nelmio/cors-bundle": {
"version": "1.5",
"recipe": {
@@ -215,21 +182,12 @@
"nikic/php-parser": {
"version": "v4.3.0"
},
"ocramius/package-versions": {
"version": "2.3.0"
},
"ocramius/proxy-manager": {
"version": "2.7.0"
},
"phar-io/manifest": {
"version": "1.0.3"
},
"phar-io/version": {
"version": "2.0.1"
},
"php": {
"version": "7.4"
},
"phpdocumentor/reflection-common": {
"version": "2.0.0"
},
@@ -257,9 +215,6 @@
"phpunit/php-timer": {
"version": "3.0.0"
},
"phpunit/php-token-stream": {
"version": "4.0.0"
},
"phpunit/phpunit": {
"version": "4.7",
"recipe": {
@@ -313,6 +268,9 @@
"react/promise": {
"version": "v2.7.1"
},
"roave/security-advisories": {
"version": "dev-latest"
},
"sebastian/cli-parser": {
"version": "1.0.1"
},
@@ -373,8 +331,17 @@
"config/packages/snc_redis.yaml"
]
},
"symfony/amqp-messenger": {
"version": "v5.1.0"
"symfony/apache-pack": {
"version": "1.0",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "master",
"version": "1.0",
"ref": "9d254a22efca7264203eea98b866f16f944b2f09"
},
"files": [
"public/.htaccess"
]
},
"symfony/asset": {
"version": "v5.0.7"
@@ -425,9 +392,6 @@
"symfony/doctrine-bridge": {
"version": "v5.0.5"
},
"symfony/doctrine-messenger": {
"version": "v5.1.0"
},
"symfony/dom-crawler": {
"version": "v5.0.5"
},
@@ -496,9 +460,6 @@
"symfony/http-kernel": {
"version": "v5.0.4"
},
"symfony/inflector": {
"version": "v5.0.5"
},
"symfony/maker-bundle": {
"version": "1.0",
"recipe": {
@@ -549,9 +510,6 @@
"symfony/polyfill-mbstring": {
"version": "v1.14.0"
},
"symfony/polyfill-php73": {
"version": "v1.14.0"
},
"symfony/polyfill-php80": {
"version": "v1.17.0"
},
@@ -573,9 +531,6 @@
"symfony/proxy-manager-bridge": {
"version": "v5.2.12"
},
"symfony/redis-messenger": {
"version": "v5.1.0"
},
"symfony/routing": {
"version": "4.2",
"recipe": {
@@ -611,9 +566,6 @@
"symfony/security-csrf": {
"version": "v5.0.5"
},
"symfony/security-guard": {
"version": "v5.0.5"
},
"symfony/security-http": {
"version": "v5.0.5"
},
@@ -703,9 +655,6 @@
"twig/twig": {
"version": "v3.0.3"
},
"webimpress/safe-writer": {
"version": "2.0.0"
},
"webmozart/assert": {
"version": "1.7.0"
},