Skip to content

Commit 6c158d0

Browse files
committed
Init
1 parent 2c2ed9a commit 6c158d0

Some content is hidden

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

65 files changed

+13207
-0
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
COMPOSE_PROJECT_NAME=symfony

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
app/tmp
3+
.DS_Store

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Symfony 6, development and deploy stack
2+
3+
*Keywords: Symfony 6.2, PHP8.2, Apache 2.4, Postgres 15.2, Docker, Redis*
4+
5+
All commands are run in the root directory.
6+
7+
### Config files
8+
| Path | Usage |
9+
| ------ | ------ |
10+
|./.env| build env variables for build via docker-compose|
11+
|./app/.env| app env variables for local development|
12+
|./app/.env.test| app env variables for test development|
13+
14+
```
15+
Or run composer commands / symfony commands in webroot directory in PHP container:
16+
```sh
17+
$ composer ci <-- all
18+
$ composer tests <-- tests
19+
$ composer ecs <-- code style check
20+
$ composer ecs-fix <-- code style check + fix
21+
$ composer phpstan <-- phpstan (level 7)
22+
```
23+
24+
## Push docker images to GitHub registry
25+
### Enable docker container registry for your account
26+
1. go to https://github.com/settings/tokens and generate new token for "repo", "write:packages", "read:packages"
27+
2. on github.com click to your account -> *Feature preview* and click to "Enable"
28+
29+
#### Acces to github private registry from localhost
30+
On your localhost run command (as password paste token from first step):
31+
```sh
32+
$ docker login ghcr.io -u [github_username]
33+
```

app/.env

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# In all environments, the following files are loaded if they exist,
2+
# the latter taking precedence over the former:
3+
#
4+
# * .env contains default values for the environment variables needed by the app
5+
# * .env.local uncommitted file with local overrides
6+
# * .env.$APP_ENV committed environment-specific defaults
7+
# * .env.$APP_ENV.local uncommitted environment-specific overrides
8+
#
9+
# Real environment variables win over .env files.
10+
#
11+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+
# https://symfony.com/doc/current/configuration/secrets.html
13+
#
14+
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
15+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
16+
17+
###> symfony/framework-bundle ###
18+
APP_ENV=dev
19+
APP_SECRET=6d8bb223f815073f477d51001a5a4284
20+
###< symfony/framework-bundle ###
21+
22+
###> doctrine/doctrine-bundle ###
23+
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
24+
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
25+
#
26+
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
27+
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=8&charset=utf8mb4"
28+
DATABASE_URL="postgresql://app:[email protected]:5432/app?serverVersion=15&charset=utf8"
29+
###< doctrine/doctrine-bundle ###
30+
31+
###> symfony/messenger ###
32+
# Choose one of the transports below
33+
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
34+
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
35+
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
36+
###< symfony/messenger ###
37+
38+
###> symfony/mailer ###
39+
# MAILER_DSN=null://null
40+
###< symfony/mailer ###
41+
42+
###> snc/redis-bundle ###
43+
# passwords that contain special characters (@, %, :, +) must be urlencoded
44+
REDIS_URL=redis://redis
45+
###< snc/redis-bundle ###

app/.env.dev

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# In all environments, the following files are loaded if they exist,
2+
# the latter taking precedence over the former:
3+
#
4+
# * .env contains default values for the environment variables needed by the app
5+
# * .env.local uncommitted file with local overrides
6+
# * .env.$APP_ENV committed environment-specific defaults
7+
# * .env.$APP_ENV.local uncommitted environment-specific overrides
8+
#
9+
# Real environment variables win over .env files.
10+
#
11+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+
# https://symfony.com/doc/current/configuration/secrets.html
13+
#
14+
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
15+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
16+
17+
###> symfony/framework-bundle ###
18+
APP_ENV=dev
19+
APP_SECRET=6d8bb223f815073f477d51001a5a4284
20+
###< symfony/framework-bundle ###
21+
22+
###> doctrine/doctrine-bundle ###
23+
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
24+
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
25+
#
26+
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
27+
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=8&charset=utf8mb4"
28+
DATABASE_URL="postgresql://appuser:apppassword@postgres:5432/symfony?serverVersion=15&charset=utf8"
29+
###< doctrine/doctrine-bundle ###
30+
31+
###> symfony/messenger ###
32+
# Choose one of the transports below
33+
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
34+
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
35+
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
36+
###< symfony/messenger ###
37+
38+
###> symfony/mailer ###
39+
# MAILER_DSN=null://null
40+
###< symfony/mailer ###
41+
42+
###> snc/redis-bundle ###
43+
# passwords that contain special characters (@, %, :, +) must be urlencoded
44+
REDIS_URL=redis://redis
45+
###< snc/redis-bundle ###

app/.env.test

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# define your env variables for the test env here
2+
KERNEL_CLASS='App\Kernel'
3+
SYMFONY_DEPRECATIONS_HELPER=999999
4+
PANTHER_APP_ENV=panther
5+
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
6+
7+
# In all environments, the following files are loaded if they exist,
8+
# the latter taking precedence over the former:
9+
#
10+
# * .env contains default values for the environment variables needed by the app
11+
# * .env.local uncommitted file with local overrides
12+
# * .env.$APP_ENV committed environment-specific defaults
13+
# * .env.$APP_ENV.local uncommitted environment-specific overrides
14+
#
15+
# Real environment variables win over .env files.
16+
#
17+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
18+
# https://symfony.com/doc/current/configuration/secrets.html
19+
#
20+
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
21+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
22+
23+
###> symfony/framework-bundle ###
24+
APP_ENV=test
25+
APP_SECRET=6d8bb223f815073f477d51001a5a4284
26+
###< symfony/framework-bundle ###
27+
28+
###> doctrine/doctrine-bundle ###
29+
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
30+
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
31+
#
32+
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
33+
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=8&charset=utf8mb4"
34+
DATABASE_URL="postgresql://appuser:apppassword@postgres:5432/symfony?serverVersion=15&charset=utf8"
35+
###< doctrine/doctrine-bundle ###
36+
37+
###> symfony/messenger ###
38+
# Choose one of the transports below
39+
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
40+
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
41+
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
42+
###< symfony/messenger ###
43+
44+
###> symfony/mailer ###
45+
# MAILER_DSN=null://null
46+
###< symfony/mailer ###
47+
48+
###> snc/redis-bundle ###
49+
# passwords that contain special characters (@, %, :, +) must be urlencoded
50+
REDIS_URL=redis://redis
51+
###< snc/redis-bundle ###

app/.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
###> symfony/framework-bundle ###
3+
/.env.local
4+
/.env.local.php
5+
/.env.*.local
6+
/config/secrets/prod/prod.decrypt.private.php
7+
/public/bundles/
8+
/var/
9+
/vendor/
10+
###< symfony/framework-bundle ###
11+
12+
###> phpunit/phpunit ###
13+
/phpunit.xml
14+
.phpunit.result.cache
15+
###< phpunit/phpunit ###
16+
17+
###> symfony/phpunit-bridge ###
18+
.phpunit.result.cache
19+
/phpunit.xml
20+
###< symfony/phpunit-bridge ###
21+
22+
###> squizlabs/php_codesniffer ###
23+
/.phpcs-cache
24+
/phpcs.xml
25+
###< squizlabs/php_codesniffer ###
26+
27+
###> friendsofphp/php-cs-fixer ###
28+
/.php-cs-fixer.php
29+
/.php-cs-fixer.cache
30+
###< friendsofphp/php-cs-fixer ###

app/.php-cs-fixer.dist.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())
4+
->in(__DIR__)
5+
->exclude('var')
6+
;
7+
8+
return (new PhpCsFixer\Config())
9+
->setRules([
10+
'@Symfony' => true,
11+
])
12+
->setFinder($finder)
13+
;

app/bin/console

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
7+
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
8+
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
9+
}
10+
11+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
12+
13+
return function (array $context) {
14+
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
15+
16+
return new Application($kernel);
17+
};

app/bin/phpunit

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
if (!ini_get('date.timezone')) {
5+
ini_set('date.timezone', 'UTC');
6+
}
7+
8+
if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
9+
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
10+
require PHPUNIT_COMPOSER_INSTALL;
11+
PHPUnit\TextUI\Command::main();
12+
} else {
13+
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
14+
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
15+
exit(1);
16+
}
17+
18+
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
19+
}

app/build/phpstan/console-loader.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
use Symfony\Component\Dotenv\Dotenv;
7+
8+
if (!is_file(dirname(__DIR__).'/../vendor/autoload_runtime.php')) {
9+
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
10+
}
11+
12+
require_once dirname(__DIR__).'/../vendor/autoload_runtime.php';
13+
14+
(new Dotenv())->bootEnv(__DIR__ . '/../../.env.test');
15+
16+
$kernel = new Kernel('test', true);
17+
18+
return new Application($kernel);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Component\Dotenv\Dotenv;
6+
7+
if (!is_file(dirname(__DIR__).'/../vendor/autoload_runtime.php')) {
8+
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
9+
}
10+
11+
require_once dirname(__DIR__).'/../vendor/autoload_runtime.php';
12+
13+
(new Dotenv())->bootEnv(__DIR__ . '/../../.env.test');
14+
15+
$kernel = new Kernel('test', true);
16+
$kernel->boot();
17+
18+
return $kernel->getContainer()->get('doctrine')->getManager();

0 commit comments

Comments
 (0)