Skip to content

Commit

Permalink
Php82 upgrade (#57)
Browse files Browse the repository at this point in the history
* Added devcontainer

* Reorganized composer dependencies

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Remove recipt default style

* Update symfony to 5.4

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Updated to symfony 5.4 and php7.4

* Update to php8 and symfony 6.4

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Update recipe

* Renamed docker compose files

* Added repository

* Add cs fixer

* Ran cs-fixer

* Added phpstan

* Added grumphp

* Added rector

* Configured logger

* Ran rector

* Ran cs fixer

* Added short names

* Ran rector

* Fix stan and cs

* Add simple smoketests

* Updated README

* Fix github build script

* Added actuator bundle

* Fix build file
  • Loading branch information
kevin-studer authored Mar 25, 2024
1 parent 5f33df8 commit 5f0ce4d
Show file tree
Hide file tree
Showing 107 changed files with 13,293 additions and 10,279 deletions.
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

0 comments on commit 5f0ce4d

Please sign in to comment.