Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task: introduce symfony framework #442

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=f438f77f277cb7fb396904bd897c6b10
###< symfony/framework-bundle ###
22 changes: 16 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
archives/
bower_components/
config/*
!config/config.inc.php
!config/tailwind.admin.config.js
/config/my.config.inc.php
data/
digicamcontrol/
HEAD
Expand All @@ -20,8 +17,6 @@ trash
vendor/PhotoSwipe/
vendor/simple-translator/
.sass-cache
/.htaccess
.htpasswd
*.patch
/welcome/.skip_welcome
.skip_welcome
Expand Down Expand Up @@ -50,4 +45,19 @@ tools/*/vendor
.idea/
**/.DS_Store

# composer
/bin/*
!/bin/composer
!/bin/console
!/bin/photobooth
/vendor/

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###
67 changes: 67 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# For a symfony application to work properly, you MUST store this .htaccess in
# the same directory as your front controller, index.php, in a standard symfony
# web application is under the "public" project subdirectory.

# Use the front controller as index file.
DirectoryIndex index.php

# Uncomment the following line if you install assets as symlinks or if you
# experience problems related to symlinks when compiling LESS/Sass/CoffeScript.
# 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

# This RewriteRule is used to dynamically discover the RewriteBase path.
# See https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
# Here we will compare the stripped per-dir path *relative to the filesystem
# path where the .htaccess file is read from* with the URI of the request.
#
# If a match is found, the prefix path is stored into an ENV var that is later
# used to properly prefix the URI of the front controller index.php.
# This is what makes it possible to host a Symfony application under a subpath,
# such as example.com/subpath

# The convoluted rewrite condition means:
# 1. Match all current URI in the RewriteRule and backreference it using $0
# 2. Strip the request uri the per-dir path and use ir as REQUEST_URI.
# This is documented in https://bit.ly/3zDm3SI ("What is matched?")
# 3. Evaluate the RewriteCond, assuming your DocumentRoot is /var/www/html,
# this .htaccess is in the /var/www/html/public dir and your request URI
# is /public/hello/world:
# * strip per-dir prefix: /var/www/html/public/hello/world -> hello/world
# * applying pattern '.*' to uri 'hello/world'
# * RewriteCond: input='/public/hello/world::hello/world' pattern='^(/.+)/(.*)::\\2$' => matched
# 4. Execute the RewriteRule:
# * The %1 in the RewriteRule flag E=BASE:%1 refers to the first group captured in the RewriteCond ^(/.+)/(.*)
# * setting env variable 'BASE' to '/public'
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]

# Removes the /index.php/ part from a URL, if present
RewriteCond %{ENV:REDIRECT_STATUS} =""
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]

# If the requested filename exists, simply serve it.
# Otherwise 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
# to the front controller explicitly so that the website
RedirectMatch 307 ^/$ /index.php/
</IfModule>
</IfModule>
2 changes: 1 addition & 1 deletion admin/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once '../lib/boot.php';
require_once 'lib/boot.php';

use Photobooth\Service\ApplicationService;
use Photobooth\Utility\PathUtility;
Expand Down
11 changes: 0 additions & 11 deletions api/sounds.php

This file was deleted.

11 changes: 0 additions & 11 deletions api/translations.php

This file was deleted.

4 changes: 2 additions & 2 deletions assets/js/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const photoboothTools = (function () {
api.isPrinting = false;

api.initialize = async function () {
const resultTranslations = await fetch(environment.publicFolders.api + '/translations.php', {
const resultTranslations = await fetch(environment.publicFolders.api + '/translations', {
cache: 'no-store'
});
this.translations = await resultTranslations.json();
const resultSounds = await fetch(environment.publicFolders.api + '/sounds.php', {
const resultSounds = await fetch(environment.publicFolders.api + '/sounds', {
cache: 'no-store'
});
this.sounds = await resultSounds.json();
Expand Down
17 changes: 17 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env php
<?php

use Photobooth\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);

return new Application($kernel);
};
28 changes: 23 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,34 @@
"ext-zip": "*",
"endroid/qr-code": "^5.0",
"league/commonmark": "^2.4",
"monolog/monolog": "^3.5",
"phpmailer/phpmailer": "^6.8",
"monolog/monolog": "^3.6",
"phpmailer/phpmailer": "^6.9",
"symfony/asset": "^7.0",
"symfony/config": "^7.0",
"symfony/console": "^7.0",
"symfony/filesystem": "^7.0",
"symfony/finder": "^7.0",
"symfony/translation": "^7.0"
"symfony/dotenv": "^7.0",
"symfony/flex": "^2.4",
"symfony/framework-bundle": "^7.0",
"symfony/runtime": "^7.0",
"symfony/translation": "^7.0",
"symfony/twig-bundle": "^7.0",
"symfony/yaml": "^7.0"
},
"require-dev": {
"symfony/debug-bundle": "^7.0",
"symfony/maker-bundle": "^1.59"
},
"config": {
"bin-dir": "bin",
"optimize-autoloader": true,
"sort-packages": true,
"vendor-dir": "vendor"
"vendor-dir": "vendor",
"allow-plugins": {
"symfony/flex": true,
"symfony/runtime": true
}
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -68,6 +82,10 @@
"composer update -w --working-dir=tools/phplint",
"composer update -w --working-dir=tools/phpunit",
"composer update -w --working-dir=tools/phpstan"
]
],
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
}
}
}
Loading
Loading