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

Php82 upgrade #57

Merged
merged 60 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
5334100
Added devcontainer
kevin-studer Mar 21, 2024
896ad62
Reorganized composer dependencies
kevin-studer Mar 21, 2024
8943bfe
Update recipe
kevin-studer Mar 21, 2024
9548d06
Update recipe
kevin-studer Mar 21, 2024
54ec188
Update recipe
kevin-studer Mar 21, 2024
3807b14
Update recipe
kevin-studer Mar 21, 2024
eb8c562
Update recipe
kevin-studer Mar 21, 2024
6ed6e60
Update recipe
kevin-studer Mar 21, 2024
0ee24c6
Update recipe
kevin-studer Mar 21, 2024
c176b41
Update recipe
kevin-studer Mar 21, 2024
56f9525
Update recipe
kevin-studer Mar 21, 2024
6fd0eea
Update recipe
kevin-studer Mar 21, 2024
c5aa13b
Update recipe
kevin-studer Mar 21, 2024
8257b2c
Update recipe
kevin-studer Mar 21, 2024
7167bbf
Update recipe
kevin-studer Mar 21, 2024
98b8284
Update recipe
kevin-studer Mar 21, 2024
c96421f
Remove recipt default style
kevin-studer Mar 21, 2024
15ea50d
Update symfony to 5.4
kevin-studer Mar 21, 2024
54328f1
Update recipe
kevin-studer Mar 21, 2024
b4c67eb
Update recipe
kevin-studer Mar 21, 2024
5621d24
Update recipe
kevin-studer Mar 21, 2024
9ad985e
Update recipe
kevin-studer Mar 21, 2024
9ceb1b4
Update recipe
kevin-studer Mar 21, 2024
e4faaf7
Update recipe
kevin-studer Mar 21, 2024
d9d96ba
Update recipe
kevin-studer Mar 21, 2024
5bc4541
Update recipe
kevin-studer Mar 21, 2024
8bb5c46
Update recipe
kevin-studer Mar 21, 2024
12ec9a7
Update recipe
kevin-studer Mar 21, 2024
68970c1
Update recipe
kevin-studer Mar 21, 2024
04ded52
Update recipe
kevin-studer Mar 21, 2024
c596bb0
Update recipe
kevin-studer Mar 21, 2024
498fcdc
Update recipe
kevin-studer Mar 21, 2024
42e34a0
Updated to symfony 5.4 and php7.4
kevin-studer Mar 21, 2024
7c6c193
Update to php8 and symfony 6.4
kevin-studer Mar 21, 2024
97c5c78
Update recipe
kevin-studer Mar 21, 2024
c72bdbf
Update recipe
kevin-studer Mar 21, 2024
7e1cd99
Update recipe
kevin-studer Mar 21, 2024
a998e53
Update recipe
kevin-studer Mar 21, 2024
eb39d84
Update recipe
kevin-studer Mar 21, 2024
560962d
Update recipe
kevin-studer Mar 21, 2024
97e1bb2
Update recipe
kevin-studer Mar 21, 2024
37eaa6e
Renamed docker compose files
kevin-studer Mar 21, 2024
f0e05fd
Added repository
kevin-studer Mar 21, 2024
6a64e34
Add cs fixer
kevin-studer Mar 21, 2024
99eb85d
Ran cs-fixer
kevin-studer Mar 21, 2024
d9370ed
Added phpstan
kevin-studer Mar 21, 2024
bbd006b
Added grumphp
kevin-studer Mar 21, 2024
914640f
Added rector
kevin-studer Mar 21, 2024
23541d5
Configured logger
kevin-studer Mar 21, 2024
8c84b03
Ran rector
kevin-studer Mar 21, 2024
5cebb71
Ran cs fixer
kevin-studer Mar 21, 2024
ebcc7bb
Added short names
kevin-studer Mar 21, 2024
23d5bea
Ran rector
kevin-studer Mar 21, 2024
0c3fad1
Fix stan and cs
kevin-studer Mar 21, 2024
0a5ee74
Add simple smoketests
kevin-studer Mar 22, 2024
b97ebdf
Updated README
kevin-studer Mar 22, 2024
dd73c32
Fix github build script
kevin-studer Mar 22, 2024
2b486d7
Merge branch 'main' into php82-upgrade
kevin-studer Mar 22, 2024
c98afdd
Added actuator bundle
kevin-studer Mar 22, 2024
db59df0
Fix build file
kevin-studer Mar 22, 2024
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
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/shyim/devcontainers-features/php:latest": {
"version": "8.2",
"extensionsExtra": "xdebug mbstring"
},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/shyim/devcontainers-features/symfony-cli:0": {},
"ghcr.io/devcontainers/features/docker-in-docker:1": {
"version": "latest",
"moby": true
}
},
"customizations": {
"vscode": {
"settings": {
"intelephense.files.maxSize": 100000000
},
"extensions": [
"DEVSENSE.phptools-vscode"
]
}
}
}
24 changes: 13 additions & 11 deletions .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# In all environments, the following files are loaded if they exist,
# the later taking precedence over the former:
# 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
Expand All @@ -9,27 +9,29 @@
# 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/configuration.html#infrastructure-related-configuration
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=b2803eb8c0caa56d1570622c2fb949d2
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
#TRUSTED_HOSTS='^localhost|example\.com$'
APP_SECRET=0ff2cdc681ec5c670bcfbbaccf80867b
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Configure your db driver and server_version in config/packages/doctrine.yaml
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
###> symfony/mailer ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=null://localhost
###< symfony/swiftmailer-bundle ###
MAILER_DSN=null://localhost
###< symfony/mailer ###
4 changes: 3 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='s$cretf0rt3st'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
134 changes: 134 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: "Build"

on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main


jobs:
phpstan:
name: "pstan"
runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.2"
extensions: "intl, json, zip"

- name: Get composer cache directory
id: composerCache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composerCache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: "Install latest dependencies"
run: composer install --ansi --no-interaction --no-progress --prefer-dist

- name: "Run phpstan"
run: php vendor/bin/phpstan analyse --error-format=github


php-cs-fixer:
name: "php-cs-fixer"
runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.2"
extensions: "intl, json, zip"

- name: Get composer cache directory
id: composerCache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composerCache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: "Install latest dependencies"
run: composer install --ansi --no-interaction --no-progress --prefer-dist

- name: "Run php-cs-fixer"
run: php vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no

phpunit:
needs: [ "phpstan", "php-cs-fixer" ]

name: "phpunit"
runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@verbose"
with:
coverage: "pcov"
php-version: "8.2"
extensions: "intl, json, zip"

- name: "Install symfony-cli"
run: |
curl -sS https://get.symfony.com/cli/installer | bash
mv $HOME/.symfony5/bin/symfony /usr/local/bin/symfony

- name: Get composer cache directory
id: composerCache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composerCache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: "Install Node"
uses: actions/setup-node@v3
with:
node-version: '18.16'

- name: "Install latest dependencies"
run: |
composer install --ansi --no-interaction --no-progress --prefer-dist
yarn

- name: "Build assets"
run: yarn encore production --color

- name: "Start services"
run: docker compose up -d --wait

- name: "Run PHPUnit"
run: symfony php vendor/bin/phpunit

- name: "Cleanup"
if: ${{ always() }}
run: docker-compose down
23 changes: 16 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> symfony/phpunit-bridge ###
.phpunit
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###

###> symfony/web-server-bundle ###
/.web-server-pid
###< symfony/web-server-bundle ###

###> symfony/webpack-encore-bundle ###
/node_modules/
/public/build/
Expand All @@ -28,3 +23,17 @@ yarn-error.log
/.idea
/data/setup_progress.json
###> custom ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.php
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###

###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###
19 changes: 19 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude('var')
->exclude('node_modules')
->exclude('vendor')
;

return (new PhpCsFixer\Config())
->setRules([
'@PhpCsFixer' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'php_unit_test_class_requires_covers' => false,
])
->setRiskyAllowed(true)
->setFinder($finder)
;
14 changes: 7 additions & 7 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ To enable automated queries an [OAI](<https://github.com/OAI/OpenAPI-Specificati

## Prerequisites

* [PHP](<https://php.net/>) 7.1.3 or newer (See [here](<https://symfony.com/doc/4.2/reference/requirements.html>) for more information about the needed php extensions)
* A database. The symfony framework is compatible with many database types. The project was tested with [MySQL](<https://www.mysql.com/>) server version 5.7.26
* [PHP](<https://php.net/>) 8.2 or newer (See [here](<https://symfony.com/doc/6.4/reference/requirements.html>) for more information about the needed php extensions)
* A database. The symfony framework is compatible with many database types. The project was tested with [PostgreSQL](<https://www.postgresql.org/>) server version 15
* [composer]((<https://getcomposer.org/>)) and [yarn](<https://yarnpkg.com/>)
* [Apache](<https://httpd.apache.org/>) or [NGINX](<https://www.nginx.com/>) webserver (See [here](<https://symfony.com/doc/4.2/setup/web_server_configuration.html>) for more information about the configuration).
* [Apache](<https://httpd.apache.org/>) or [NGINX](<https://www.nginx.com/>) webserver (See [here](<https://symfony.com/doc/6.4/setup/web_server_configuration.html>) for more information about the configuration).
During development Symfony's built-in webserver can be used.

## Installation

Clone the repository:

```bash
git clone https://github.com/UB-Bern/bernhist.git
git clone https://github.com/ub-unibe-ch/bernhist.git
```

Change to the created directory and run:
Expand Down Expand Up @@ -61,13 +61,13 @@ Create the database schema:
bin/console doctrine:schema:create
```

Extract `data.tar.gz` in the project root and import the SQL data dump:
Import the sql file `data.sql.gz` in the database:

```
mysql -u [username] -p [database] < [path to data dir]/bernhist_data.sql
gunzip -c data.sql.gz | psql -u [username] -p [database]
```

Replace [username] with the mysql user, [database] with the name of your database and [path to data dir] with the relative or absolute path to the extracted mysql dump.
Replace [username] with the mysql user, [database] with the name of your database.

Install the frontend dependencies with:

Expand Down
12 changes: 12 additions & 0 deletions assets/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Welcome to your app's main JavaScript file!
*
* We recommend including the built version of this JavaScript file
* (and its CSS file) in your base layout (base.html.twig).
*/

// any CSS you import will output into a single css file (app.css in this case)
import './styles/app.css';

// start the Stimulus application
import './bootstrap';
11 changes: 11 additions & 0 deletions assets/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { startStimulusApp } from '@symfony/stimulus-bridge';

// Registers Stimulus controllers from controllers.json and in the controllers/ directory
export const app = startStimulusApp(require.context(
'@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
true,
/\.[jt]sx?$/
));

// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);
4 changes: 4 additions & 0 deletions assets/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"controllers": [],
"entrypoints": []
}
16 changes: 16 additions & 0 deletions assets/controllers/hello_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Controller } from '@hotwired/stimulus';

/*
* This is an example Stimulus controller!
*
* Any element with a data-controller="hello" attribute will cause
* this controller to be executed. The name "hello" comes from the filename:
* hello_controller.js -> "hello"
*
* Delete this file or adapt it for your use!
*/
export default class extends Controller {
connect() {
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
}
}
2 changes: 1 addition & 1 deletion assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ $('.year-select').change(function(){
let yearTo = $('#year-to').val();
url = url.replace('.yearFrom.', yearFrom).replace('.yearTo.', yearTo);
document.location.href = url;
});
});
File renamed without changes.
Loading
Loading