Skip to content

Commit ec84f0d

Browse files
author
dmitriy
committed
updated to php 7.4 and laravel 6.13, improved environment
1 parent 897e813 commit ec84f0d

Some content is hidden

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

68 files changed

+8582
-2582
lines changed

.bitbucket/dependencies.sh

Lines changed: 10 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ jobs:
2626
command: |
2727
make phpunit
2828
29+
- run:
30+
name: Report code coverage
31+
command: |
32+
make report-code-coverage
33+
2934
- store_artifacts:
3035
path: reports
3136

.env.dev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ MAIL_PORT=2525
2929
MAIL_USERNAME=null
3030
MAIL_PASSWORD=null
3131
MAIL_ENCRYPTION=null
32+
MAIL_FROM_ADDRESS=null
33+
MAIL_FROM_NAME="${APP_NAME}"
3234

3335
AWS_ACCESS_KEY_ID=
3436
AWS_SECRET_ACCESS_KEY=

.env.prod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ MAIL_PORT=2525
2929
MAIL_USERNAME=null
3030
MAIL_PASSWORD=null
3131
MAIL_ENCRYPTION=null
32+
MAIL_FROM_ADDRESS=null
33+
MAIL_FROM_NAME="${APP_NAME}"
3234

3335
AWS_ACCESS_KEY_ID=
3436
AWS_SECRET_ACCESS_KEY=

.env.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ MAIL_PORT=2525
2929
MAIL_USERNAME=null
3030
MAIL_PASSWORD=null
3131
MAIL_ENCRYPTION=null
32+
MAIL_FROM_ADDRESS=null
33+
MAIL_FROM_NAME="${APP_NAME}"
3234

3335
AWS_ACCESS_KEY_ID=
3436
AWS_SECRET_ACCESS_KEY=

.env.test-ci

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ MAIL_PORT=2525
3030
MAIL_USERNAME=null
3131
MAIL_PASSWORD=null
3232
MAIL_ENCRYPTION=null
33+
MAIL_FROM_ADDRESS=null
34+
MAIL_FROM_NAME="${APP_NAME}"
35+
36+
AWS_ACCESS_KEY_ID=
37+
AWS_SECRET_ACCESS_KEY=
38+
AWS_DEFAULT_REGION=us-east-1
39+
AWS_BUCKET=
3340

3441
PUSHER_APP_ID=
3542
PUSHER_APP_KEY=

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Laravel 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 seeds
34+
run: make seed
35+
- name: Run test suite
36+
run: make phpunit
37+
- name: Stop the docker images
38+
run: make stop-test

Dockerfile

Lines changed: 7 additions & 7 deletions
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
@@ -51,17 +51,17 @@ RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
5151
RUN chown -R www-data:www-data $APP_HOME
5252

5353
# put apache and php config for Laravel, enable sites
54-
COPY ./docker/hosts/laravel.conf /etc/apache2/sites-available/laravel.conf
55-
COPY ./docker/hosts/laravel-ssl.conf /etc/apache2/sites-available/laravel-ssl.conf
54+
COPY ./docker/general/laravel.conf /etc/apache2/sites-available/laravel.conf
55+
COPY ./docker/general/laravel-ssl.conf /etc/apache2/sites-available/laravel-ssl.conf
5656
RUN a2ensite laravel.conf && a2ensite laravel-ssl
5757
COPY ./docker/$BUILD_ARGUMENT_ENV/php.ini /usr/local/etc/php/php.ini
5858

5959
# enable apache modules
6060
RUN a2enmod rewrite
6161
RUN a2enmod ssl
6262

63-
# install Xdebug in case development environment
64-
COPY ./docker/other/do_we_need_xdebug.sh /tmp/
63+
# install Xdebug in case development or test environment
64+
COPY ./docker/general/do_we_need_xdebug.sh /tmp/
6565
COPY ./docker/dev/xdebug.ini /tmp/
6666
RUN chmod u+x /tmp/do_we_need_xdebug.sh && /tmp/do_we_need_xdebug.sh
6767

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

7171
# add supervisor
7272
RUN mkdir -p /var/log/supervisor
73-
COPY --chown=root:root ./docker/other/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
74-
COPY --chown=root:root ./docker/other/cron /var/spool/cron/crontabs/root
73+
COPY --chown=root:root ./docker/general/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
74+
COPY --chown=root:root ./docker/general/cron /var/spool/cron/crontabs/root
7575
RUN chmod 0600 /var/spool/cron/crontabs/root
7676

7777
# generate certificates

Makefile

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
dir=${CURDIR}
22
project=-p laravel
33
service=laravel: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
@@ -31,7 +35,7 @@ env-test-ci:
3135
@make exec cmd="cp ./.env.test-ci ./.env"
3236

3337
ssh:
34-
@docker-compose $(project) exec laravel bash
38+
@docker-compose $(project) exec $(optionT) laravel bash
3539

3640
ssh-supervisord:
3741
@docker-compose $(project) exec supervisord bash
@@ -40,14 +44,17 @@ ssh-mysql:
4044
@docker-compose $(project) exec mysql bash
4145

4246
exec:
43-
@docker-compose $(project) exec laravel $$cmd
47+
@docker-compose $(project) exec $(optionT) laravel $$cmd
4448

45-
clean:
46-
rm -rf $(dir)/reports/*
49+
exec-bash:
50+
@docker-compose $(project) exec $(optionT) laravel bash -c "$(cmd)"
4751

48-
prepare:
52+
report-prepare:
4953
mkdir -p $(dir)/reports/coverage
5054

55+
report-clean:
56+
rm -rf $(dir)/reports/*
57+
5158
wait-for-db:
5259
@make exec cmd="php artisan db:wait"
5360

@@ -88,4 +95,37 @@ seed:
8895
@make exec cmd="php artisan db:seed --force"
8996

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

app/Console/Commands/DbWaitDatabase.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class DbWaitDatabase extends Command
4040
public function handle(DB $db): int
4141
{
4242
for ($i = 0; $i < 60; $i += self::WAIT_SLEEP_TIME) {
43-
4443
try {
4544
$db::select('SHOW TABLES');
4645
$this->info('Connection to the database is ok!');
@@ -52,7 +51,6 @@ public function handle(DB $db): int
5251

5352
continue;
5453
}
55-
5654
}
5755

5856
$this->error('Can not connect to the database');

app/Exceptions/Handler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class Handler extends ExceptionHandler
3131
*
3232
* @param \Exception $exception
3333
* @return void
34+
*
35+
* @throws \Exception
3436
*/
3537
public function report(Exception $exception)
3638
{
@@ -42,7 +44,9 @@ public function report(Exception $exception)
4244
*
4345
* @param \Illuminate\Http\Request $request
4446
* @param \Exception $exception
45-
* @return \Illuminate\Http\Response
47+
* @return \Symfony\Component\HttpFoundation\Response
48+
*
49+
* @throws \Exception
4650
*/
4751
public function render($request, Exception $exception)
4852
{

app/Http/Controllers/Auth/ConfirmPasswordController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Http\Controllers\Auth;
44

55
use App\Http\Controllers\Controller;
6+
use App\Providers\RouteServiceProvider;
67
use Illuminate\Foundation\Auth\ConfirmsPasswords;
78

89
class ConfirmPasswordController extends Controller
@@ -25,7 +26,7 @@ class ConfirmPasswordController extends Controller
2526
*
2627
* @var string
2728
*/
28-
protected $redirectTo = '/home';
29+
protected $redirectTo = RouteServiceProvider::HOME;
2930

3031
/**
3132
* Create a new controller instance.

app/Http/Controllers/Auth/LoginController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Http\Controllers\Auth;
44

55
use App\Http\Controllers\Controller;
6+
use App\Providers\RouteServiceProvider;
67
use Illuminate\Foundation\Auth\AuthenticatesUsers;
78

89
class LoginController extends Controller
@@ -25,7 +26,7 @@ class LoginController extends Controller
2526
*
2627
* @var string
2728
*/
28-
protected $redirectTo = '/home';
29+
protected $redirectTo = RouteServiceProvider::HOME;
2930

3031
/**
3132
* Create a new controller instance.

app/Http/Controllers/Auth/RegisterController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Http\Controllers\Auth;
44

55
use App\Http\Controllers\Controller;
6+
use App\Providers\RouteServiceProvider;
67
use App\User;
78
use Illuminate\Foundation\Auth\RegistersUsers;
89
use Illuminate\Support\Facades\Hash;
@@ -28,7 +29,7 @@ class RegisterController extends Controller
2829
*
2930
* @var string
3031
*/
31-
protected $redirectTo = '/home';
32+
protected $redirectTo = RouteServiceProvider::HOME;
3233

3334
/**
3435
* Create a new controller instance.

app/Http/Controllers/Auth/ResetPasswordController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Http\Controllers\Auth;
44

55
use App\Http\Controllers\Controller;
6+
use App\Providers\RouteServiceProvider;
67
use Illuminate\Foundation\Auth\ResetsPasswords;
78

89
class ResetPasswordController extends Controller
@@ -25,5 +26,5 @@ class ResetPasswordController extends Controller
2526
*
2627
* @var string
2728
*/
28-
protected $redirectTo = '/home';
29+
protected $redirectTo = RouteServiceProvider::HOME;
2930
}

app/Http/Controllers/Auth/VerificationController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Http\Controllers\Auth;
44

55
use App\Http\Controllers\Controller;
6+
use App\Providers\RouteServiceProvider;
67
use Illuminate\Foundation\Auth\VerifiesEmails;
78

89
class VerificationController extends Controller
@@ -25,7 +26,7 @@ class VerificationController extends Controller
2526
*
2627
* @var string
2728
*/
28-
protected $redirectTo = '/home';
29+
protected $redirectTo = RouteServiceProvider::HOME;
2930

3031
/**
3132
* Create a new controller instance.

app/Http/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Kernel extends HttpKernel
3939

4040
'api' => [
4141
'throttle:60,1',
42-
'bindings',
42+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
4343
],
4444
];
4545

app/Http/Middleware/Authenticate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Authenticate extends Middleware
1010
* Get the path the user should be redirected to when they are not authenticated.
1111
*
1212
* @param \Illuminate\Http\Request $request
13-
* @return string
13+
* @return string|null
1414
*/
1515
protected function redirectTo($request)
1616
{

app/Http/Middleware/RedirectIfAuthenticated.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Http\Middleware;
44

5+
use App\Providers\RouteServiceProvider;
56
use Closure;
67
use Illuminate\Support\Facades\Auth;
78

@@ -18,7 +19,7 @@ class RedirectIfAuthenticated
1819
public function handle($request, Closure $next, $guard = null)
1920
{
2021
if (Auth::guard($guard)->check()) {
21-
return redirect('/home');
22+
return redirect(RouteServiceProvider::HOME);
2223
}
2324

2425
return $next($request);

app/Providers/RouteServiceProvider.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ class RouteServiceProvider extends ServiceProvider
1616
*/
1717
protected $namespace = 'App\Http\Controllers';
1818

19+
/**
20+
* The path to the "home" route for your application.
21+
*
22+
* @var string
23+
*/
24+
public const HOME = '/home';
25+
1926
/**
2027
* Define your route model bindings, pattern filters, etc.
2128
*

artisan

100755100644
File mode changed.

0 commit comments

Comments
 (0)