Skip to content

Commit 519fad8

Browse files
committed
task: introduce symfony framework
1 parent 7c133d1 commit 519fad8

21 files changed

+2778
-428
lines changed

.env

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# In all environments, the following files are loaded if they exist,
2+
# the latter taking precedence over the former:
3+
#
4+
# * .env contains default values for the environment variables needed by the app
5+
# * .env.local uncommitted file with local overrides
6+
# * .env.$APP_ENV committed environment-specific defaults
7+
# * .env.$APP_ENV.local uncommitted environment-specific overrides
8+
#
9+
# Real environment variables win over .env files.
10+
#
11+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+
# https://symfony.com/doc/current/configuration/secrets.html
13+
#
14+
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
15+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
16+
17+
###> symfony/framework-bundle ###
18+
APP_ENV=dev
19+
APP_SECRET=f438f77f277cb7fb396904bd897c6b10
20+
###< symfony/framework-bundle ###

.gitignore

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
archives/
2-
bower_components/
3-
config/*
4-
!config/config.inc.php
5-
!config/tailwind.admin.config.js
2+
/config/my.config.inc.php
63
data/
74
digicamcontrol/
85
HEAD
@@ -20,8 +17,6 @@ trash
2017
vendor/PhotoSwipe/
2118
vendor/simple-translator/
2219
.sass-cache
23-
/.htaccess
24-
.htpasswd
2520
*.patch
2621
/welcome/.skip_welcome
2722
.skip_welcome
@@ -49,4 +44,19 @@ tools/*/vendor
4944
.idea/
5045
**/.DS_Store
5146

47+
# composer
48+
/bin/*
49+
!/bin/composer
50+
!/bin/console
51+
!/bin/photobooth
5252
/vendor/
53+
54+
###> symfony/framework-bundle ###
55+
/.env.local
56+
/.env.local.php
57+
/.env.*.local
58+
/config/secrets/prod/prod.decrypt.private.php
59+
/public/bundles/
60+
/var/
61+
/vendor/
62+
###< symfony/framework-bundle ###

.htaccess

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# For a symfony application to work properly, you MUST store this .htaccess in
2+
# the same directory as your front controller, index.php, in a standard symfony
3+
# web application is under the "public" project subdirectory.
4+
5+
# Use the front controller as index file.
6+
DirectoryIndex index.php
7+
8+
# Uncomment the following line if you install assets as symlinks or if you
9+
# experience problems related to symlinks when compiling LESS/Sass/CoffeScript.
10+
# Options +FollowSymlinks
11+
12+
# Disabling MultiViews prevents unwanted negotiation, e.g. "/index" should not resolve
13+
# to the front controller "/index.php" but be rewritten to "/index.php/index".
14+
<IfModule mod_negotiation.c>
15+
Options -MultiViews
16+
</IfModule>
17+
18+
<IfModule mod_rewrite.c>
19+
RewriteEngine On
20+
21+
# This RewriteRule is used to dynamically discover the RewriteBase path.
22+
# See https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
23+
# Here we will compare the stripped per-dir path *relative to the filesystem
24+
# path where the .htaccess file is read from* with the URI of the request.
25+
#
26+
# If a match is found, the prefix path is stored into an ENV var that is later
27+
# used to properly prefix the URI of the front controller index.php.
28+
# This is what makes it possible to host a Symfony application under a subpath,
29+
# such as example.com/subpath
30+
31+
# The convoluted rewrite condition means:
32+
# 1. Match all current URI in the RewriteRule and backreference it using $0
33+
# 2. Strip the request uri the per-dir path and use ir as REQUEST_URI.
34+
# This is documented in https://bit.ly/3zDm3SI ("What is matched?")
35+
# 3. Evaluate the RewriteCond, assuming your DocumentRoot is /var/www/html,
36+
# this .htaccess is in the /var/www/html/public dir and your request URI
37+
# is /public/hello/world:
38+
# * strip per-dir prefix: /var/www/html/public/hello/world -> hello/world
39+
# * applying pattern '.*' to uri 'hello/world'
40+
# * RewriteCond: input='/public/hello/world::hello/world' pattern='^(/.+)/(.*)::\\2$' => matched
41+
# 4. Execute the RewriteRule:
42+
# * The %1 in the RewriteRule flag E=BASE:%1 refers to the first group captured in the RewriteCond ^(/.+)/(.*)
43+
# * setting env variable 'BASE' to '/public'
44+
RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
45+
RewriteRule .* - [E=BASE:%1]
46+
47+
# Sets the HTTP_AUTHORIZATION header removed by Apache
48+
RewriteCond %{HTTP:Authorization} .+
49+
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
50+
51+
# Removes the /index.php/ part from a URL, if present
52+
RewriteCond %{ENV:REDIRECT_STATUS} =""
53+
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
54+
55+
# If the requested filename exists, simply serve it.
56+
# Otherwise rewrite all other queries to the front controller.
57+
RewriteCond %{REQUEST_FILENAME} !-f
58+
RewriteRule ^ %{ENV:BASE}/index.php [L]
59+
</IfModule>
60+
61+
<IfModule !mod_rewrite.c>
62+
<IfModule mod_alias.c>
63+
# When mod_rewrite is not available, we instruct a temporary redirect
64+
# to the front controller explicitly so that the website
65+
RedirectMatch 307 ^/$ /index.php/
66+
</IfModule>
67+
</IfModule>

bin/console

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use Photobooth\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
7+
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
8+
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
9+
}
10+
11+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
12+
13+
return function (array $context) {
14+
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
15+
16+
return new Application($kernel);
17+
};

composer.json

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,22 @@
1414
"phpmailer/phpmailer": "^6.8",
1515
"symfony/asset": "^6.3",
1616
"symfony/console": "^6.3",
17-
"symfony/translation": "^6.3"
17+
"symfony/dotenv": "^6.3",
18+
"symfony/flex": "^2.4",
19+
"symfony/framework-bundle": "^6.3",
20+
"symfony/runtime": "^6.3",
21+
"symfony/translation": "^6.3",
22+
"symfony/yaml": "^6.3"
1823
},
1924
"config": {
2025
"bin-dir": "bin",
2126
"optimize-autoloader": true,
2227
"sort-packages": true,
23-
"vendor-dir": "vendor"
28+
"vendor-dir": "vendor",
29+
"allow-plugins": {
30+
"symfony/flex": true,
31+
"symfony/runtime": true
32+
}
2433
},
2534
"autoload": {
2635
"psr-4": {
@@ -60,6 +69,13 @@
6069
"composer update -w --working-dir=tools/php-cs-fixer",
6170
"composer update -w --working-dir=tools/phplint",
6271
"composer update -w --working-dir=tools/phpunit"
63-
]
72+
],
73+
"auto-scripts": {
74+
"cache:clear": "symfony-cmd",
75+
"assets:install %PUBLIC_DIR%": "symfony-cmd"
76+
}
77+
},
78+
"require-dev": {
79+
"symfony/debug-bundle": "^6.3"
6480
}
6581
}

0 commit comments

Comments
 (0)