diff --git a/.env.dist b/.env.dist index 866090c..705b033 100644 --- a/.env.dist +++ b/.env.dist @@ -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 diff --git a/README.md b/README.md index 6821e05..9053262 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 @@ -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. @@ -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 -``` +``` \ No newline at end of file diff --git a/composer.json b/composer.json index cc92e33..467113a 100644 --- a/composer.json +++ b/composer.json @@ -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": { @@ -40,6 +56,8 @@ } }, "replace": { + "paragonie/random_compat": "2.*", + "symfony/polyfill-ctype": "*", "symfony/polyfill-iconv": "*" }, "scripts": { @@ -57,8 +75,8 @@ }, "extra": { "symfony": { - "id": "", - "allow-contrib": false + "allow-contrib": false, + "require": "4.4.*" } } } diff --git a/config/deployer/hosts.yaml b/config/deployer/hosts.yaml deleted file mode 100644 index acae79a..0000000 --- a/config/deployer/hosts.yaml +++ /dev/null @@ -1,12 +0,0 @@ -dev: - hostname: domain.com # Replace with proper domain - deploy_path: /var/www/domain.com # Replace with proper deploy path - branch: develop - user: deploy - stage: dev -#prod: -# hostname: domain.com # Replace with proper domain -# deploy_path: /var/www/domain.com # Replace with proper deploy path -# branch: master -# user: deploy -# stage: prod diff --git a/config/docker/php/docker-entrypoint.sh b/config/docker/dev/docker-entrypoint.sh similarity index 100% rename from config/docker/php/docker-entrypoint.sh rename to config/docker/dev/docker-entrypoint.sh diff --git a/config/docker/php/symfony.pool.conf b/config/docker/dev/symfony.pool.conf similarity index 100% rename from config/docker/php/symfony.pool.conf rename to config/docker/dev/symfony.pool.conf diff --git a/config/docker/php/symfony.ini b/config/docker/php/symfony.ini deleted file mode 100644 index e8ac18e..0000000 --- a/config/docker/php/symfony.ini +++ /dev/null @@ -1,3 +0,0 @@ -date.timezone = UTC -memory_limit = -1 -max_execution_time=3000 diff --git a/config/docker/php/xdebug.ini b/config/docker/php/xdebug.ini deleted file mode 100644 index 63abbce..0000000 --- a/config/docker/php/xdebug.ini +++ /dev/null @@ -1,4 +0,0 @@ -xdebug.remote_enable=on -xdebug.remote_autostart=on -xdebug.remote_connect_back=1 -xdebug.remote_port=9000 diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index 6f9b466..0c217b0 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -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: diff --git a/deploy.php b/deploy.php deleted file mode 100644 index aa6cf63..0000000 --- a/deploy.php +++ /dev/null @@ -1,24 +0,0 @@ -> /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 @@ -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/ \ No newline at end of file +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/ \ No newline at end of file diff --git a/docker-compose-sync.yml b/docker-compose-sync.yml index 503ad8b..0b8131e 100644 --- a/docker-compose-sync.yml +++ b/docker-compose-sync.yml @@ -1,4 +1,4 @@ -version: '3.2' +version: '3.7' services: php: diff --git a/docker-compose.yml b/docker-compose.yml index bf60a54..34b01c9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: @@ -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: diff --git a/tests/Functional/ApplicationAvailabilityFunctionalTest.php b/tests/Functional/ApplicationAvailabilityFunctionalTest.php new file mode 100644 index 0000000..0daf8d1 --- /dev/null +++ b/tests/Functional/ApplicationAvailabilityFunctionalTest.php @@ -0,0 +1,26 @@ +request('GET', $url); + + $this->assertResponseIsSuccessful(); + } + + public function urlProvider() + { + yield ['/']; + } +} diff --git a/tests/Unit/.gitkeep b/tests/Unit/.gitkeep new file mode 100644 index 0000000..e69de29