Skip to content

Commit 4dcc56a

Browse files
author
dmitriy
committed
updated to php 7.4 and symfony 4.4
1 parent 723b3e7 commit 4dcc56a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+10478
-2733
lines changed

.bitbucket/dependencies.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env sh
2+
3+
set -eu
4+
5+
# Add python pip and bash
6+
apk add --no-cache py-pip bash make
7+
8+
# Install docker-compose via pip
9+
pip install --no-cache-dir docker-compose~=1.23.0
10+
docker-compose -v

.circleci/config.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ jobs:
1919
command: |
2020
make wait-for-db
2121
make drop-migrate
22-
make fixtures
2322
2423
- run:
2524
name: Run unit/functional tests
2625
command: |
2726
make phpunit
2827
28+
- run:
29+
name: Report code coverage
30+
command: |
31+
make report-code-coverage
32+
2933
- store_artifacts:
3034
path: reports
3135

.dockerignore

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
/.git*
22
/.idea*
3-
var/mysql-data
4-
var/rabbitmq
5-
vendor/
63
.dockerignore
74
.editorconfig
5+
6+
/.env.local
7+
/.env.*.local
88
.env.local.php
9+
/public/bundles/
10+
/var/mysql-data
11+
/var/rabbitmq
12+
/vendor/
13+
/tools/*/vendor/
14+
915
Dockerfile
1016
docker-compose.yml
1117
docker-compose-test-ci.yml
1218
docker-compose-prod.yml
13-
Makefile

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ trim_trailing_whitespace = false
1313

1414
[*.yml]
1515
indent_size = 2
16+
17+
[{composer.json,Makefile}]
18+
indent_style = tab

.env

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# In all environments, the following files are loaded if they exist,
2-
# the later taking precedence over the former:
2+
# the latter taking precedence over the former:
33
#
44
# * .env contains default values for the environment variables needed by the app
55
# * .env.local uncommitted file with local overrides
@@ -11,28 +11,27 @@
1111
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
1212
#
1313
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
14-
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
14+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
1515

1616
###> symfony/framework-bundle ###
1717
APP_ENV=dev
18+
APP_DEBUG=1
1819
APP_SECRET=42f011ec3a7bde0bec87364b1d967193
19-
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
20+
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
2021
#TRUSTED_HOSTS='^localhost|example\.com$'
2122
###< symfony/framework-bundle ###
2223

2324
###> doctrine/doctrine-bundle ###
2425
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
2526
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
26-
# Configure your db driver and server_version in config/packages/doctrine.yaml
27+
# For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&charset=utf8"
28+
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
2729
DATABASE_URL=mysql://root:secret@mysql:3306/symfony
2830
###< doctrine/doctrine-bundle ###
2931

30-
###> symfony/swiftmailer-bundle ###
31-
# For Gmail as a transport, use: "gmail://username:password@localhost"
32-
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
33-
# Delivery is disabled by default via "null://localhost"
34-
MAILER_URL=null://localhost
35-
###< symfony/swiftmailer-bundle ###
32+
###> symfony/mailer ###
33+
# MAILER_DSN=smtp://localhost
34+
###< symfony/mailer ###
3635

3736
###> symfony/messenger ###
3837
MESSENGER_TRANSPORT_DSN=amqp://guest:guest@rabbitmq:5672/%2f/messages

.github/workflows/ci.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Symfony App
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- develop
8+
pull_request:
9+
branches:
10+
- master
11+
- develop
12+
release:
13+
types: [published]
14+
15+
jobs:
16+
17+
build:
18+
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v1
23+
- name: Build the docker images
24+
run: docker-compose -f docker-compose-test-ci.yml build
25+
- name: Start the docker images
26+
run: make start-test
27+
- name: Check running containers
28+
run: docker ps -a
29+
- name: Wait for database connection
30+
run: make wait-for-db
31+
- name: Run migrations
32+
run: make drop-migrate
33+
- name: Run test suite
34+
run: make phpunit
35+
- name: Stop the docker images
36+
run: make stop-test

.gitignore

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
/.idea
22
reports/*
33
!reports/.gitkeep
4-
.phpunit.result.cache
54

65
###> symfony/framework-bundle ###
76
/.env.local
87
/.env.local.php
98
/.env.*.local
9+
/config/secrets/prod/prod.decrypt.private.php
1010
/public/bundles/
1111
/var/
1212
/vendor/
1313
###< symfony/framework-bundle ###
1414

1515
###> symfony/phpunit-bridge ###
1616
.phpunit
17+
.phpunit.result.cache
1718
/phpunit.xml
1819
###< symfony/phpunit-bridge ###
19-
20-
###> symfony/web-server-bundle ###
21-
/.web-server-pid
22-
###< symfony/web-server-bundle ###

Dockerfile

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:7.3-apache
1+
FROM php:7.4-apache
22

33
# set main params
44
ARG BUILD_ARGUMENT_DEBUG_ENABLED=false
@@ -55,8 +55,8 @@ RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
5555
RUN chown -R www-data:www-data $APP_HOME
5656

5757
# put apache and php config for Symfony, enable sites
58-
COPY ./docker/hosts/symfony.conf /etc/apache2/sites-available/symfony.conf
59-
COPY ./docker/hosts/symfony-ssl.conf /etc/apache2/sites-available/symfony-ssl.conf
58+
COPY ./docker/general/symfony.conf /etc/apache2/sites-available/symfony.conf
59+
COPY ./docker/general/symfony-ssl.conf /etc/apache2/sites-available/symfony-ssl.conf
6060
RUN a2ensite symfony.conf && a2ensite symfony-ssl
6161
COPY ./docker/$BUILD_ARGUMENT_ENV/php.ini /usr/local/etc/php/php.ini
6262

@@ -65,7 +65,7 @@ RUN a2enmod rewrite
6565
RUN a2enmod ssl
6666

6767
# install Xdebug in case development or test environment
68-
COPY ./docker/other/do_we_need_xdebug.sh /tmp/
68+
COPY ./docker/general/do_we_need_xdebug.sh /tmp/
6969
COPY ./docker/dev/xdebug.ini /tmp/
7070
RUN chmod u+x /tmp/do_we_need_xdebug.sh && /tmp/do_we_need_xdebug.sh
7171

@@ -74,8 +74,8 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/
7474

7575
# add supervisor
7676
RUN mkdir -p /var/log/supervisor
77-
COPY --chown=root:root ./docker/other/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
78-
COPY --chown=root:root ./docker/other/cron /var/spool/cron/crontabs/root
77+
COPY --chown=root:root ./docker/general/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
78+
COPY --chown=root:root ./docker/general/cron /var/spool/cron/crontabs/root
7979
RUN chmod 0600 /var/spool/cron/crontabs/root
8080

8181
# generate certificates

Makefile

+63-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
dir=${CURDIR}
22
project=-p symfony
33
service=symfony:latest
4+
interactive:=$(shell [ -t 0 ] && echo 1)
5+
ifneq ($(interactive),1)
6+
optionT=-T
7+
endif
48

59
start:
610
@docker-compose -f docker-compose.yml $(project) up -d
@@ -28,20 +32,29 @@ env-prod:
2832
@make exec cmd="composer dump-env prod"
2933

3034
ssh:
31-
@docker-compose $(project) exec symfony bash
35+
@docker-compose $(project) exec $(optionT) symfony bash
3236

3337
ssh-supervisord:
3438
@docker-compose $(project) exec supervisord bash
3539

40+
ssh-mysql:
41+
@docker-compose $(project) exec mysql bash
42+
43+
ssh-rabbitmq:
44+
@docker-compose $(project) exec rabbitmq /bin/sh
45+
3646
exec:
37-
@docker-compose $(project) exec symfony $$cmd
47+
@docker-compose $(project) exec $(optionT) symfony $$cmd
3848

39-
clean:
40-
rm -rf $(dir)/reports/*
49+
exec-bash:
50+
@docker-compose $(project) exec $(optionT) symfony bash -c "$(cmd)"
4151

42-
prepare:
52+
report-prepare:
4353
mkdir -p $(dir)/reports/coverage
4454

55+
report-clean:
56+
rm -rf $(dir)/reports/*
57+
4558
wait-for-db:
4659
@make exec cmd="php bin/console db:wait"
4760

@@ -58,8 +71,17 @@ info:
5871
@make exec cmd="bin/console --version"
5972
@make exec cmd="php --version"
6073

74+
logs:
75+
@docker logs -f symfony
76+
6177
logs-supervisord:
62-
@docker logs supervisord
78+
@docker logs -f supervisord
79+
80+
logs-mysql:
81+
@docker logs -f mysql
82+
83+
logs-rabbitmq:
84+
@docker logs -f rabbitmq
6385

6486
drop-migrate:
6587
@make exec cmd="php bin/console doctrine:schema:drop --full-database --force"
@@ -74,7 +96,40 @@ migrate:
7496
@make exec cmd="php bin/console doctrine:migrations:migrate --no-interaction --env=test"
7597

7698
fixtures:
77-
@make exec cmd="php bin/console doctrine:fixtures:load --append"
99+
@make exec cmd="php bin/console doctrine:fixtures:load --env=test"
78100

79101
phpunit:
80-
@make exec cmd="./vendor/bin/simple-phpunit -c phpunit.xml.dist --log-junit reports/phpunit.xml --coverage-html reports/coverage --coverage-clover reports/coverage.xml"
102+
@make exec cmd="./vendor/bin/phpunit -c phpunit.xml.dist --coverage-html reports/coverage --coverage-clover reports/clover.xml --log-junit reports/junit.xml"
103+
104+
###> php-coveralls ###
105+
report-code-coverage: ## update code coverage on coveralls.io. Note: COVERALLS_REPO_TOKEN should be set on CI side.
106+
@make exec-bash cmd="export COVERALLS_REPO_TOKEN=${COVERALLS_REPO_TOKEN} && php ./vendor/bin/php-coveralls -v --coverage_clover reports/clover.xml --json_path reports/coverals.json"
107+
###< php-coveralls ###
108+
109+
###> phpcs ###
110+
phpcs: ## Run PHP CodeSniffer
111+
@make exec-bash cmd="./vendor/bin/phpcs --version && ./vendor/bin/phpcs --standard=PSR2 --colors -p src"
112+
###< phpcs ###
113+
114+
###> ecs ###
115+
ecs: ## Run Easy Coding Standard
116+
@make exec-bash cmd="error_reporting=0 ./vendor/bin/ecs --clear-cache check src"
117+
118+
ecs-fix: ## Run The Easy Coding Standard to fix issues
119+
@make exec-bash cmd="error_reporting=0 ./vendor/bin/ecs --clear-cache --fix check src"
120+
###< ecs ###
121+
122+
###> phpmetrics ###
123+
phpmetrics:
124+
@make exec cmd="make phpmetrics-process"
125+
126+
phpmetrics-process: ## Generates PhpMetrics static analysis, should be run inside symfony container
127+
@mkdir -p reports/phpmetrics
128+
@if [ ! -f reports/junit.xml ] ; then \
129+
printf "\033[32;49mjunit.xml not found, running tests...\033[39m\n" ; \
130+
./vendor/bin/phpunit -c phpunit.xml.dist --coverage-html reports/coverage --coverage-clover reports/clover.xml --log-junit reports/junit.xml ; \
131+
fi;
132+
@echo "\033[32mRunning PhpMetrics\033[39m"
133+
@php ./vendor/bin/phpmetrics --version
134+
@./vendor/bin/phpmetrics --junit=reports/junit.xml --report-html=reports/phpmetrics .
135+
###< phpmetrics ###

bin/console

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
#!/usr/bin/env php
22
<?php
3+
declare(strict_types = 1);
34

45
use App\Kernel;
56
use Symfony\Bundle\FrameworkBundle\Console\Application;
67
use Symfony\Component\Console\Input\ArgvInput;
7-
use Symfony\Component\Debug\Debug;
8+
use Symfony\Component\ErrorHandler\Debug;
89

9-
if (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
10-
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL;
10+
if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
11+
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
1112
}
1213

1314
set_time_limit(0);
1415

1516
require dirname(__DIR__).'/vendor/autoload.php';
1617

1718
if (!class_exists(Application::class)) {
18-
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
19+
throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.');
1920
}
2021

2122
$input = new ArgvInput();

bin/phpunit

-13
This file was deleted.

bitbucket-pipelines.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
image: docker:stable
2+
3+
options:
4+
docker: true
5+
6+
pipelines:
7+
default:
8+
- step:
9+
script:
10+
- chmod +x .bitbucket/dependencies.sh
11+
- .bitbucket/dependencies.sh
12+
- docker-compose -f docker-compose-test-ci.yml build
13+
- make start-test
14+
- docker ps -a
15+
- make wait-for-db
16+
- make drop-migrate
17+
- make phpunit
18+
- make stop-test

0 commit comments

Comments
 (0)