Merge pull request 'Add dotenv package and .env file' (#3) from feature/dotenvfile into master

Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
2024-11-15 09:32:07 +01:00
7 changed files with 87 additions and 5 deletions

2
.env Normal file
View File

@@ -0,0 +1,2 @@
APP_ENV=prod
APP_DEBUG=false

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
.idea
database.sqlite
var/cache/
.env.local

View File

@@ -14,7 +14,8 @@
1. Cd into project directory
2. Run `git pull`
3. Start and build image in one go with command: `docker compose up -d --build --force-recreate`
3. Refresh cache on production by removing cache directory: `rm -rf var/cache`
4. Start and build image in one go with command: `docker compose up -d --build --force-recreate`
## Running Cron

View File

@@ -9,7 +9,8 @@
"laravel/serializable-closure": "^1.3",
"symfony/http-kernel": "^7.1",
"symfony/framework-bundle": "^7.1",
"symfony/twig-bundle": "^7.1"
"symfony/twig-bundle": "^7.1",
"symfony/dotenv": "^7.1"
},
"autoload": {
"psr-4": {

76
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "9c0c7b968c4acc975c2de9bd993c6645",
"content-hash": "f2dfc64ddf11dc6a94b37f7eac9ffc0f",
"packages": [
{
"name": "brick/math",
@@ -2176,6 +2176,80 @@
],
"time": "2024-04-18T09:32:20+00:00"
},
{
"name": "symfony/dotenv",
"version": "v7.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/dotenv.git",
"reference": "6d966200b399fa59759286f3fc7c919f0677c449"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dotenv/zipball/6d966200b399fa59759286f3fc7c919f0677c449",
"reference": "6d966200b399fa59759286f3fc7c919f0677c449",
"shasum": ""
},
"require": {
"php": ">=8.2"
},
"conflict": {
"symfony/console": "<6.4",
"symfony/process": "<6.4"
},
"require-dev": {
"symfony/console": "^6.4|^7.0",
"symfony/process": "^6.4|^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Dotenv\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Registers environment variables from a .env file",
"homepage": "https://symfony.com",
"keywords": [
"dotenv",
"env",
"environment"
],
"support": {
"source": "https://github.com/symfony/dotenv/tree/v7.1.5"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-17T09:16:35+00:00"
},
{
"name": "symfony/error-handler",
"version": "v7.1.3",

View File

@@ -2,6 +2,7 @@
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
@@ -37,8 +38,9 @@ class Kernel extends BaseKernel
$routes->import(__DIR__.'/src/Controller/', 'attribute');
}
}
(new Dotenv())->bootEnv(__DIR__.'/.env');
$kernel = new Kernel('prod', false);
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();

View File

@@ -11,6 +11,7 @@
<th>Categories</th>
<th></th>
<th>Price</th>
<th></th>
</tr>
</thead>
{% for product in products %}