Skip to content

Commit 1333385

Browse files
committed
task: introduce symfony framework
1 parent ea25b03 commit 1333385

33 files changed

+3190
-444
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
@@ -50,4 +45,19 @@ tools/*/vendor
5045
.idea/
5146
**/.DS_Store
5247

48+
# composer
49+
/bin/*
50+
!/bin/composer
51+
!/bin/console
52+
!/bin/photobooth
5353
/vendor/
54+
55+
###> symfony/framework-bundle ###
56+
/.env.local
57+
/.env.local.php
58+
/.env.*.local
59+
/config/secrets/prod/prod.decrypt.private.php
60+
/public/bundles/
61+
/var/
62+
/vendor/
63+
###< 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>

admin/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
require_once '../lib/boot.php';
3+
require_once 'lib/boot.php';
44

55
use Photobooth\Service\ApplicationService;
66
use Photobooth\Utility\PathUtility;

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: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,34 @@
1010
"ext-zip": "*",
1111
"endroid/qr-code": "^5.0",
1212
"league/commonmark": "^2.4",
13-
"monolog/monolog": "^3.5",
14-
"phpmailer/phpmailer": "^6.8",
13+
"monolog/monolog": "^3.6",
14+
"phpmailer/phpmailer": "^6.9",
1515
"symfony/asset": "^7.0",
1616
"symfony/config": "^7.0",
1717
"symfony/console": "^7.0",
1818
"symfony/filesystem": "^7.0",
1919
"symfony/finder": "^7.0",
20-
"symfony/translation": "^7.0"
20+
"symfony/dotenv": "^7.0",
21+
"symfony/flex": "^2.4",
22+
"symfony/framework-bundle": "^7.0",
23+
"symfony/runtime": "^7.0",
24+
"symfony/translation": "^7.0",
25+
"symfony/twig-bundle": "^7.0",
26+
"symfony/yaml": "^7.0"
27+
},
28+
"require-dev": {
29+
"symfony/debug-bundle": "^7.0",
30+
"symfony/maker-bundle": "^1.59"
2131
},
2232
"config": {
2333
"bin-dir": "bin",
2434
"optimize-autoloader": true,
2535
"sort-packages": true,
26-
"vendor-dir": "vendor"
36+
"vendor-dir": "vendor",
37+
"allow-plugins": {
38+
"symfony/flex": true,
39+
"symfony/runtime": true
40+
}
2741
},
2842
"autoload": {
2943
"psr-4": {
@@ -68,6 +82,10 @@
6882
"composer update -w --working-dir=tools/phplint",
6983
"composer update -w --working-dir=tools/phpunit",
7084
"composer update -w --working-dir=tools/phpstan"
71-
]
85+
],
86+
"auto-scripts": {
87+
"cache:clear": "symfony-cmd",
88+
"assets:install %PUBLIC_DIR%": "symfony-cmd"
89+
}
7290
}
7391
}

0 commit comments

Comments
 (0)