From 0152f6fa1ac016f24c78b826b8ef62b32119214d Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 17 Dec 2019 21:20:24 +0100 Subject: [PATCH] Added dev php config and removed .env dependencies --- .env.dist | 10 ---------- .gitattributes | 1 - .gitignore | 1 - composer.json | 1 - config/autoload/entity-manager.global.php | 6 +++--- config/autoload/entity-manager.local.php.dist | 5 +++++ config/autoload/url-shortener.global.php | 6 ++---- config/autoload/url-shortener.local.php.dist | 14 ++++++++++++++ config/container.php | 9 --------- config/test/bootstrap_api_tests.php | 8 -------- config/test/bootstrap_db_tests.php | 8 -------- data/infra/php.ini | 7 ++++++- docker-compose.yml | 3 ++- 13 files changed, 32 insertions(+), 47 deletions(-) delete mode 100644 .env.dist create mode 100644 config/autoload/url-shortener.local.php.dist diff --git a/.env.dist b/.env.dist deleted file mode 100644 index daf74cbb..00000000 --- a/.env.dist +++ /dev/null @@ -1,10 +0,0 @@ -# Application -APP_ENV= -SECRET_KEY= -SHORTENED_URL_SCHEMA= -SHORTENED_URL_HOSTNAME= - -# Database -DB_USER= -DB_PASSWORD= -DB_NAME= diff --git a/.gitattributes b/.gitattributes index df9095a4..80102b6f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,7 +9,6 @@ /module/PreviewGenerator/test-db export-ignore /module/Rest/test export-ignore /module/Rest/test-api export-ignore -.env.dist export-ignore .gitattributes export-ignore .gitignore export-ignore .phpstorm.meta.php export-ignore diff --git a/.gitignore b/.gitignore index 7b14364c..ab121a93 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ build composer.lock composer.phar vendor/ -.env data/database.sqlite data/shlink-tests.db data/GeoLite2-City.mmdb diff --git a/composer.json b/composer.json index 84290c2a..c1563613 100644 --- a/composer.json +++ b/composer.json @@ -65,7 +65,6 @@ "roave/security-advisories": "dev-master", "shlinkio/php-coding-standard": "~2.0.0", "shlinkio/shlink-test-utils": "^1.2", - "symfony/dotenv": "^5.0", "symfony/var-dumper": "^5.0" }, "autoload": { diff --git a/config/autoload/entity-manager.global.php b/config/autoload/entity-manager.global.php index bd847f5a..561579f1 100644 --- a/config/autoload/entity-manager.global.php +++ b/config/autoload/entity-manager.global.php @@ -11,9 +11,9 @@ return [ 'proxies_dir' => 'data/proxies', ], 'connection' => [ - 'user' => env('DB_USER'), - 'password' => env('DB_PASSWORD'), - 'dbname' => env('DB_NAME', 'shlink'), + 'user' => '', + 'password' => '', + 'dbname' => 'shlink', 'charset' => 'utf8', ], ], diff --git a/config/autoload/entity-manager.local.php.dist b/config/autoload/entity-manager.local.php.dist index cb53a6ae..3c38fb82 100644 --- a/config/autoload/entity-manager.local.php.dist +++ b/config/autoload/entity-manager.local.php.dist @@ -1,8 +1,13 @@ [ 'connection' => [ + 'user' => 'root', + 'password' => 'root', 'driver' => 'pdo_mysql', 'host' => 'shlink_db', 'driverOptions' => [ diff --git a/config/autoload/url-shortener.global.php b/config/autoload/url-shortener.global.php index 7c7e19de..46e12593 100644 --- a/config/autoload/url-shortener.global.php +++ b/config/autoload/url-shortener.global.php @@ -2,14 +2,12 @@ declare(strict_types=1); -use function Shlinkio\Shlink\Common\env; - return [ 'url_shortener' => [ 'domain' => [ - 'schema' => env('SHORTENED_URL_SCHEMA', 'http'), - 'hostname' => env('SHORTENED_URL_HOSTNAME'), + 'schema' => 'https', + 'hostname' => '', ], 'validate_url' => true, ], diff --git a/config/autoload/url-shortener.local.php.dist b/config/autoload/url-shortener.local.php.dist new file mode 100644 index 00000000..11155ba7 --- /dev/null +++ b/config/autoload/url-shortener.local.php.dist @@ -0,0 +1,14 @@ + [ + 'domain' => [ + 'schema' => 'http', + 'hostname' => '', + ], + ], + +]; diff --git a/config/container.php b/config/container.php index f2c1d0c7..3df59ed9 100644 --- a/config/container.php +++ b/config/container.php @@ -2,21 +2,12 @@ declare(strict_types=1); -use Symfony\Component\Dotenv\Dotenv; use Zend\ServiceManager\ServiceManager; chdir(dirname(__DIR__)); require 'vendor/autoload.php'; -// If the Dotenv class exists, load env vars and enable errors -if (class_exists(Dotenv::class)) { - error_reporting(E_ALL); - ini_set('display_errors', '1'); - $dotenv = new Dotenv(true); - $dotenv->load(__DIR__ . '/../.env'); -} - // Build container $config = require __DIR__ . '/config.php'; $container = new ServiceManager($config['dependencies']); diff --git a/config/test/bootstrap_api_tests.php b/config/test/bootstrap_api_tests.php index 562986c1..3605427c 100644 --- a/config/test/bootstrap_api_tests.php +++ b/config/test/bootstrap_api_tests.php @@ -7,14 +7,6 @@ namespace Shlinkio\Shlink\TestUtils; use Doctrine\ORM\EntityManager; use Psr\Container\ContainerInterface; -use function file_exists; -use function touch; - -// Create an empty .env file -if (! file_exists('.env')) { - touch('.env'); -} - /** @var ContainerInterface $container */ $container = require __DIR__ . '/../container.php'; $testHelper = $container->get(Helper\TestHelper::class); diff --git a/config/test/bootstrap_db_tests.php b/config/test/bootstrap_db_tests.php index e5e88e20..9f14c38d 100644 --- a/config/test/bootstrap_db_tests.php +++ b/config/test/bootstrap_db_tests.php @@ -6,14 +6,6 @@ namespace Shlinkio\Shlink\TestUtils; use Psr\Container\ContainerInterface; -use function file_exists; -use function touch; - -// Create an empty .env file -if (! file_exists('.env')) { - touch('.env'); -} - /** @var ContainerInterface $container */ $container = require __DIR__ . '/../container.php'; $container->get(Helper\TestHelper::class)->createTestDb(); diff --git a/data/infra/php.ini b/data/infra/php.ini index 9c1e3f01..5ef7b7ea 100644 --- a/data/infra/php.ini +++ b/data/infra/php.ini @@ -1 +1,6 @@ -date.timezone = Europe/Madrid +display_errors=On +error_reporting=-1 +memory_limit=-1 +log_errors_max_len=0 +zend.assertions=1 +assert.exception=1 diff --git a/docker-compose.yml b/docker-compose.yml index 811eec69..99cc93fb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ version: '3' services: shlink_nginx: container_name: shlink_nginx - image: nginx:1.15.9-alpine + image: nginx:1.17.6-alpine ports: - "8000:80" volumes: @@ -37,6 +37,7 @@ services: - "9001:9001" volumes: - ./:/home/shlink + - ./data/infra/php.ini:/usr/local/etc/php/php.ini links: - shlink_db - shlink_db_postgres