Skip to content

Commit

Permalink
Merge pull request #6 from rk4xxicom/4.4
Browse files Browse the repository at this point in the history
Bumped symfony to 4.4, revised list of dependencies, minor updates in docker configs
  • Loading branch information
rk4xxicom authored May 19, 2020
2 parents 50160a9 + 168487e commit c89bd29
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 109 deletions.
20 changes: 14 additions & 6 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
# Docker configuration
HOST_UID=
EXTERNAL_HTTP_PORT=80
EXTERNAL_POSTGRES_PORT=5432
EXTERNAL_DB_PORT=5432
EXTERNAL_SMTP_PORT=1025
EXTERNAL_SMTP_WEB_PORT=8025

# PHP_IDE_CONFIG is necessary for xDebug
# Create server mapping in PHPStorm with name Default
# or change serverName value to appropriate one
PHP_IDE_CONFIG=serverName=Default

# Postgres credentials
POSTGRES_PASSWORD=dev
POSTGRES_USER=dev
POSTGRES_DB=dev

###> 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
DATABASE_URL=pgsql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
DB_HOST=db
DB_PASSWORD=dev
DB_USER=dev
DB_NAME=dev
###< doctrine/doctrine-bundle ###

###> symfony/mailer ###
MAILER_DSN=smtp://mailhog:1025
###< symfony/mailer ###

SYMFONY_PHPUNIT_VERSION=9.1.1
25 changes: 8 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
It's main idea is to keep simplicity of official Skeleton, while adding must-have dependencies and default configs used
in 4xxi for developing majority of the projects. It contains bare Symfony Skeleton with the following additions:

* A minimal set of must have bundles for production environment
* A minimal set of must-have bundles for production environment
* ORM Pack (Doctrine + Migrations)
* FrameworkExtraBundle (Annotations)
* MonologBundle
* Sensiolabs SecurityChecker
* A set of bundles and tools that are necessary for development
* [PHP CS Fixer](https://cs.sensiolabs.org/)
* [Deployer](https://deployer.org/)
* [Psalm](https://psalm.dev/docs/)
* [PhpStan](https://phpstan.org/user-guide/getting-started)
* [PhpUnit](https://symfony.com/doc/current/testing.html)
* Debug Pack (Debug + Profiler + Dumper)
* Docker Compose and Docker Sync configs optimized for development under Linux and MacOS
* Deployer config
* Template for README.md with installation instructions

Creating new project
Expand All @@ -42,13 +43,6 @@ on Linux and MacOS.
`config/docker/php/Dockerfile`.
* Optional: Add additinal services (like Redis, RabbitMQ, Elasticsearch) in docker-compose.yml.

### Deployer
Deployer is pre-configured for Symfony Flex directory structure and deployment flow used in 4xxi. The only things that
are left for manual configuration are repository settings and deploy targets:

* Update `deploy.php` with proper project name and repository configuration.
* Update `config/deployer/hosts.yaml` with proper configuration for deployment targets.

### Add Bundles and dependencies that are required by our project
Projects created by Flex include only the mininum amount of dependencies by default. Most of additional components that
were previously a part of Symfony Standard Edition are not installed, so it is up to you to install them if they are
Expand All @@ -62,14 +56,9 @@ The list of common Components that may be needed for the project:

* api
* asset
* form
* security
* serializer
* mailer
* translation
* twig
* validator
* workflow
* web-link

### Update installation instructions

Expand All @@ -90,6 +79,8 @@ your project.

Application configuration is stored in `.env` file.

Run `cp .env.dist .env` to apply the default configuration for local installations.

### HTTP port
If you have nginx or apache installed and using 80 port on host system you can either stop them before proceeding or
reconfigure Docker to use another port by changing value of `EXTERNAL_HTTP_PORT` in `.env` file.
Expand Down Expand Up @@ -151,4 +142,4 @@ docker-compose exec php vendor/bin/php-cs-fixer fix
Run PHP Unit Tests:
```bash
docker-compose exec php bin/phpunit
```
```
48 changes: 33 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,40 @@
"license": "MIT",
"require": {
"php": "^7.3",
"ext-ctype": "*",
"ext-iconv": "*",
"sensio/framework-extra-bundle": "~5.2.0",
"sensiolabs/security-checker": "~5.0.0",
"symfony/console": "~4.2.0",
"symfony/flex": "~1.1.0",
"symfony/framework-bundle": "~4.2.0",
"symfony/monolog-bundle": "~3.3.0",
"symfony/orm-pack": "~1.0.0",
"symfony/yaml": "~4.2.0",
"symfony/dotenv": "~4.2.0"
"symfony/flex": "^1.3.1"
},
"flex-require": {
"sensio/framework-extra-bundle": "^5.1",
"symfony/console": "*",
"symfony/dotenv": "*",
"symfony/expression-language": "*",
"symfony/form": "*",
"symfony/framework-bundle": "*",
"symfony/http-client": "*",
"symfony/intl": "*",
"symfony/mailer": "*",
"symfony/monolog-bundle": "^3.1",
"symfony/orm-pack": "*",
"symfony/process": "*",
"symfony/security-bundle": "*",
"symfony/serializer-pack": "*",
"symfony/translation": "*",
"symfony/validator": "*",
"symfony/yaml": "*"
},
"require-dev": {
"deployer/deployer": "^6.4",
"friendsofphp/php-cs-fixer": "^2.14",
"symfony/debug-pack": "^1.0"
"vimeo/psalm": "^3.8",
"weirdan/doctrine-psalm-plugin": "^0.8.0",
"phpstan/phpstan": "^0.12"
},
"suggest": {
"symfony/maker-bundle": "To have an ability of simple creation of common classes via console."
"flex-require-dev": {
"symfony/debug-pack": "*",
"symfony/maker-bundle": "^1.0",
"symfony/profiler-pack": "*",
"symfony/test-pack": "*"
},
"config": {
"preferred-install": {
Expand All @@ -40,6 +56,8 @@
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*"
},
"scripts": {
Expand All @@ -57,8 +75,8 @@
},
"extra": {
"symfony": {
"id": "",
"allow-contrib": false
"allow-contrib": false,
"require": "4.4.*"
}
}
}
12 changes: 0 additions & 12 deletions config/deployer/hosts.yaml

This file was deleted.

File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions config/docker/php/symfony.ini

This file was deleted.

4 changes: 0 additions & 4 deletions config/docker/php/xdebug.ini

This file was deleted.

14 changes: 10 additions & 4 deletions config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@ parameters:
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): ''
env(DB_NAME): ''
env(DB_USER): ''
env(DB_PASSWORD): ''
env(DB_HOST): ''

doctrine:
dbal:
driver: 'pdo_pgsql'
server_version: '10.6'
server_version: '12.2'

url: '%env(DATABASE_URL)%'
dbname: '%env(DB_NAME)%'
user: '%env(DB_USER)%'
password: '%env(DB_PASSWORD)%'
host: '%env(DB_HOST)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
Expand Down
24 changes: 0 additions & 24 deletions deploy.php

This file was deleted.

23 changes: 9 additions & 14 deletions config/docker/php/Dockerfile → dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.3-fpm-alpine
FROM php:7.4-fpm-alpine

RUN apk add --no-cache \
git \
Expand All @@ -14,17 +14,11 @@ RUN docker-php-ext-install \
pdo_pgsql \
zip

# Uncomment code below for enabling xDebug
# or delete it with the xdebug.ini file

#RUN apk add --no-cache --virtual .xdebug-build-deps ${PHPIZE_DEPS} \
# && pecl install xdebug \
# && docker-php-ext-enable xdebug \
# && apk del .xdebug-build-deps
#
#COPY xdebug.ini /usr/local/etc/php/xdebug.ini
#
#RUN cat /usr/local/etc/php/xdebug.ini >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
ARG XDEBUG=yes
RUN if [ "${XDEBUG}" = "yes" ]; then apk add --no-cache --virtual .xdebug-build-deps ${PHPIZE_DEPS} \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& apk del .xdebug-build-deps; fi;

COPY --from=composer /usr/bin/composer /usr/bin/composer

Expand All @@ -42,5 +36,6 @@ RUN if [ ! -z "${HOST_UID}" ]; then \

ENV WWW_DATA_UID ${HOST_UID}

COPY ./symfony.ini /usr/local/etc/php/conf.d/
COPY ./symfony.pool.conf /usr/local/etc/php-fpm.d/
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

COPY ./config/docker/dev/symfony.pool.conf /usr/local/etc/php-fpm.d/
2 changes: 1 addition & 1 deletion docker-compose-sync.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.2'
version: '3.7'

services:
php:
Expand Down
26 changes: 17 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
version: '3.2'
version: '3.7'

services:
php:
build:
context: ./config/docker/php
context: ./
dockerfile: dev.Dockerfile
args:
- HOST_UID=${HOST_UID}
depends_on:
Expand All @@ -13,29 +14,36 @@ services:
- .:/var/www/html
expose:
- "9000"
entrypoint: ./config/docker/php/docker-entrypoint.sh
entrypoint: ./config/docker/dev/docker-entrypoint.sh
environment:
- COMPOSER_HOME=/var/www/html/var/composer
- PHP_IDE_CONFIG
- APP_ENV
- SYMFONY_PHPUNIT_VERSION
nginx:
image: 4xxi/nginx:flex
depends_on:
- php
ports:
- "${EXTERNAL_HTTP_PORT}:80"
- "${EXTERNAL_HTTP_PORT-80}:80"
volumes:
- .:/var/www/html
- ./var/log:/var/log/nginx
db:
image: postgres:10.6
image: postgres:12.2
ports:
- "${EXTERNAL_POSTGRES_PORT}:5432"
- "${EXTERNAL_DB_PORT-5432}:5432"
volumes:
- db:/var/lib/postgresql/data
environment:
- POSTGRES_DB
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_DB="${DB_NAME-dev}"
- POSTGRES_USER="${DB_USER-dev}"
- POSTGRES_PASSWORD="${DB_PASSWORD-dev}"
mailhog:
image: mailhog/mailhog
ports:
- "${EXTERNAL_SMTP_PORT-8025}:1025"
- "${EXTERNAL_SMTP_WEB_PORT-8025}:8025"

volumes:
db:
26 changes: 26 additions & 0 deletions tests/Functional/ApplicationAvailabilityFunctionalTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);

namespace App\Tests;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

final class ApplicationAvailabilityFunctionalTest extends WebTestCase
{
/**
* @test
* @dataProvider urlProvider
*/
public function pageIsSuccessful($url)
{
$client = self::createClient();
$client->request('GET', $url);

$this->assertResponseIsSuccessful();
}

public function urlProvider()
{
yield ['/'];
}
}
Empty file added tests/Unit/.gitkeep
Empty file.

0 comments on commit c89bd29

Please sign in to comment.