Skip to content

Commit

Permalink
Upgrade to PHP8.3, Symfony 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
quentin-st committed Oct 11, 2024
1 parent 3161824 commit fe5b7bb
Show file tree
Hide file tree
Showing 55 changed files with 5,365 additions and 4,229 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:

docker:
# specify the version you desire here
- image: circleci/php:7.4
- image: cimg/php:8.3

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
- image: cimg/mysql:5.7
# documented at https://circleci.com/docs/circleci-images/
- image: cimg/mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: 'secured_password'
MYSQL_DATABASE: openchurch
Expand Down
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ DATABASE_URL=mysql://%MYSQL_USER%:%MYSQL_PASSWORD%@%DB_HOST%:%DB_PORT%/%MYSQL_DA

ES_HOST=127.0.0.1
ES_PORT=9200
ES_ENABLED=false
ES_ENABLED=true
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@

# Python venv
/scripts/.venv

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

###> phpunit/phpunit ###
/phpunit.xml
###< phpunit/phpunit ###
Expand All @@ -78,3 +73,8 @@ yarn-error.log
/.php_cs.cache
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###

###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.4-apache
FROM php:8.3-apache
MAINTAINER Hozana team

# Add necesary libraries
Expand All @@ -15,11 +15,17 @@ RUN apt-get update \
# needed for nodejs:
gnupg \
# needed for php's zip extensions:
zlib1g-dev
zlib1g-dev \
# needed for composer:
unzip

# Add PHP extensions
RUN docker-php-ext-install mbstring pdo pdo_mysql zip

# Install symfony binary
RUN curl -sS https://get.symfony.com/cli/installer | bash
RUN mv /root/.symfony5/bin/symfony /usr/local/bin/symfony

# Add Node.js for npm install
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y --force-yes nodejs
Expand Down
40 changes: 31 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ BrowserStack is a useful tool to test our app on different browsers, different O

To build and start the app:

```
```bash
# build docker image
cp .env.dist .env
docker-compose build
docker-compose up
docker compose build
docker compose up

# install
docker exec -it openchurch composer install
Expand All @@ -29,13 +29,17 @@ docker exec -it openchurch yarn run dev

# import database
mysql -uopenchurch -popenchurch -h 127.0.0.1 -P 13306 openchurch < data/20180806-openchurch.sql
docker exec -it openchurch bin/console doctrine:schema:update --force
docker exec -it openchurch bin/console doctrine:migrations:migrate

# index data in ES
docker exec -it openchurch bin/console fos:elastica:populate
# tip: you can specify the index to populate:
docker exec -it openchurch bin/console fos:elastica:populate --index=churches
docker exec -it openchurch bin/console fos:elastica:populate --index=parishes
docker exec -it openchurch bin/console fos:elastica:populate --index=dioceses

# run API
docker exec -it openchurch bin/console server:run 0.0.0.0:8000
docker exec -it openchurch symfony server:start --port=8000

# run backoffice
docker exec -it openchurch sh -c "cd openchurch-admin && npm start"
Expand Down Expand Up @@ -84,9 +88,9 @@ To generate our schema we first used `vendor/bin/schema generate-types config/sc

### To start the API

To test the app: `bin/console server:run` in project root folder and then reach [http://127.0.0.1:8000](http://127.0.0.1:8000). There is also a GraphiQL interface to help you write down your GraphQL requests : [http://localhost:8000/api/graphql](http://localhost:8000/api/graphql).
To test the app: `docker exec -it openchurch symfony server:start --port=8000` in project root folder and then reach [http://127.0.0.1:8000](http://127.0.0.1:8000). There is also a GraphiQL interface to help you write down your GraphQL requests : [http://localhost:8000/api/graphql](http://localhost:8000/api/graphql).

- To create a oAuth2 client to test the API: `bin/console oauth:client:create client_credentials` (or use the upcoming web interface).
~~- To create a oAuth2 client to test the API: `bin/console oauth:client:create client_credentials` (or use the upcoming web interface).~~
- To fill Elasticsearch: `bin/console fos:elastica:populate`.
- To generate the assets `yarn run dev` (and `yarn run watch` while developing).

Expand All @@ -104,7 +108,7 @@ In `openchurch-admin/src/App.js` you can define the API's URL : it's the only co

### To synchronize the database from Wikidata

```
```bash
cd scripts
python3 -m venv .venv
source .venv/bin/activate
Expand All @@ -114,10 +118,28 @@ PYWIKIBOT_NO_USER_CONFIG=1 python3 synchro.py

If you need to override the MySQL configuration of your `.env` file:

```
```bash
DB_HOST=127.0.0.1 DB_PORT=13306 PYWIKIBOT_NO_USER_CONFIG=1 python3 synchro.py
```

### To run tests
Inspired by `.circleci/config.yml`

```bash
# Start the stack
docker compose up -d
docker exec -it openchurch bash
bin/console doctrine:migration:migrate -n --env=test

apt-get update && apt-get install -y mariadb-client
mysql -h db -u openchurch -popenchurch openchurch < src/DataFixtures/fixtures.sql

bin/console fos:elastica:populate --env=test

# Run tests outside of docker
bin/phpunit
```

## For Elasticsearch

On a VM:
Expand Down
36 changes: 9 additions & 27 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,19 @@

use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
use Symfony\Component\Dotenv\Dotenv;

set_time_limit(0);

require __DIR__.'/../vendor/autoload.php';

if (!class_exists(Application::class)) {
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
if (!is_dir(dirname(__DIR__).'/vendor')) {
throw new LogicException('Dependencies are missing. Try running "composer install".');
}

if (!isset($_SERVER['APP_ENV'])) {
if (!class_exists(Dotenv::class)) {
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}
(new Dotenv())->load(__DIR__.'/../.env');
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}

$input = new ArgvInput();
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true);
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true);
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

if ($debug) {
umask(0000);

if (class_exists(Debug::class)) {
Debug::enable();
}
}
return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);

$kernel = new Kernel($env, $debug);
$application = new Application($kernel);
$application->run($input);
return new Application($kernel);
};
92 changes: 50 additions & 42 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,66 +1,75 @@
{
"name": "hozana/openchurch",
"description": "An open database for churches using Symfony 4, API platform and ElasticSearch.",
"description": "An open database for churches using Symfony, API platform and ElasticSearch.",
"type": "project",
"license": "Apache-2.0",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": "^7.4.5",
"php": "^8.3",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "^2.6,<2.7",
"api-platform/core": "^2.6.5",
"composer/package-versions-deprecated": "1.11.99.5",
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^1.12",
"doctrine/doctrine-migrations-bundle": "^1.3",
"doctrine/orm": "^2.7",
"fresh/doctrine-enum-bundle": "^6.2",
"doctrine/annotations": "^2.0",
"doctrine/doctrine-bundle": "^2.12",
"doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^2.19",
"fresh/doctrine-enum-bundle": "^7.4",
"friendsofsymfony/elastica-bundle": "^6.0",
"friendsofsymfony/oauth-server-bundle": "^1.6",
"friendsofsymfony/user-bundle": "~2.0",
"friendsofsymfony/user-bundle": "~3.0",
"myclabs/php-enum": "^1.6",
"nelmio/cors-bundle": "^2.2",
"phpdocumentor/reflection-docblock": "^4.3",
"phpdocumentor/reflection-docblock": "^5.4",
"sentry/sentry-symfony": "^4.4",
"stof/doctrine-extensions-bundle": "^1.3",
"symfony/asset": "^3.3|^4.0",
"symfony/console": "^4.1",
"symfony/dotenv": "^4.1",
"symfony/expression-language": "^4.1",
"symfony/flex": "^1.0",
"symfony/form": "^4.1",
"symfony/framework-bundle": "^4.1",
"symfony/lts": "^4@dev",
"symfony/property-access": "^4.1",
"symfony/property-info": "^4.1",
"symfony/security-bundle": "^4.1",
"symfony/serializer": "^4.1",
"symfony/templating": "^4.1",
"symfony/translation": "^4.1",
"symfony/twig-bundle": "^4.1",
"symfony/validator": "^4.1",
"symfony/web-server-bundle": "^4.1",
"symfony/yaml": "^4.1",
"symfony/asset": "5.4.*",
"symfony/console": "5.4.*",
"symfony/dotenv": "5.4.*",
"symfony/expression-language": "5.4.*",
"symfony/flex": "^1.17|^2",
"symfony/form": "5.4.*",
"symfony/framework-bundle": "5.4.*",
"symfony/property-access": "5.4.*",
"symfony/property-info": "5.4.*",
"symfony/runtime": "5.4.*",
"symfony/security-bundle": "5.4.*",
"symfony/serializer": "5.4.*",
"symfony/templating": "5.4.*",
"symfony/translation": "5.4.*",
"symfony/twig-bundle": "5.4.*",
"symfony/validator": "5.4.*",
"symfony/yaml": "5.4.*",
"twig/extra-bundle": "^2.12|^3.0",
"twig/twig": "^2.12|^3.0",
"webonyx/graphql-php": "^14.0"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"friendsofphp/php-cs-fixer": "^3.0",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^6.5",
"symfony/browser-kit": "^4.1",
"symfony/css-selector": "^4.1",
"phpunit/phpunit": "^9.5",
"symfony/browser-kit": "5.4.*",
"symfony/css-selector": "5.4.*",
"symfony/debug-bundle": "5.4.*",
"symfony/maker-bundle": "^1.9",
"symfony/stopwatch": "^4.1",
"symfony/web-profiler-bundle": "^4.1"
"symfony/phpunit-bridge": "^7.1",
"symfony/stopwatch": "5.4.*",
"symfony/web-profiler-bundle": "5.4.*"
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"php-http/discovery": true,
"symfony/flex": true,
"symfony/runtime": true
},
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true,
"allow-plugins": {
"symfony/flex": true
}
"sort-packages": true
},
"autoload": {
"psr-4": {
Expand All @@ -75,9 +84,7 @@
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
"symfony/polyfill-php72": "*"
},
"scripts": {
"auto-scripts": {
Expand All @@ -96,7 +103,8 @@
},
"extra": {
"symfony": {
"allow-contrib": false
"allow-contrib": false,
"require": "5.4.*"
}
}
}
Loading

0 comments on commit fe5b7bb

Please sign in to comment.