Revize af43940b
Přidáno uživatelem Tomáš Ballák před téměř 5 roky(ů)
docker-compose-dev.yml | ||
---|---|---|
1 | 1 |
version: "3.2" |
2 | 2 |
services: |
3 | 3 |
php-fpm: |
4 |
build: './docker/php-fpm/dev' |
|
4 | 5 |
volumes: |
5 |
- vscode-extensions-php:/var/www/symgfony/.vscode-server/extensions |
|
6 |
- vscode-extensions-php:/var/www/symfony/.vscode-server/extensions |
|
7 |
- ./logs/xdebug:/var/www/symfony/xdebug |
|
6 | 8 |
crawler: |
7 | 9 |
build: |
8 | 10 |
context: ./modules/crawler |
docker-compose.yml | ||
---|---|---|
35 | 35 |
ports: |
36 | 36 |
- "80:80" |
37 | 37 |
volumes: |
38 |
- ./logs:/var/nginx/log |
|
38 |
- ./logs/nginx:/var/nginx/log
|
|
39 | 39 |
- ./website/:/var/www/symfony |
40 | 40 |
container_name: "heatmap_nginx" |
41 | 41 |
database: |
docker/php-fpm/dev/Dockerfile | ||
---|---|---|
2 | 2 |
FROM php:7.4-fpm-alpine |
3 | 3 |
RUN apk update; \ |
4 | 4 |
apk upgrade; \ |
5 |
apk add --no-cache $PHPIZE_DEPS \ |
|
6 |
&& pecl install xdebug-2.9.5 \ |
|
7 |
&& docker-php-ext-enable xdebug \ |
|
5 | 8 |
apk add autoconf openssl-dev g++ make && \ |
6 | 9 |
pecl install mongodb && \ |
7 | 10 |
docker-php-ext-enable mongodb; \ |
8 | 11 |
apk del --purge autoconf openssl-dev g++ make; |
9 |
|
|
10 |
RUN echo "**** install Python ****" && \ |
|
11 |
apk add --no-cache python3 && \ |
|
12 |
if [ ! -e /usr/bin/python ]; then ln -sf python3 /usr/bin/python ; fi && \ |
|
13 |
\ |
|
14 |
echo "**** install pip ****" && \ |
|
15 |
python3 -m ensurepip && \ |
|
16 |
rm -r /usr/lib/python*/ensurepip && \ |
|
17 |
pip3 install --no-cache --upgrade pip setuptools wheel && \ |
|
18 |
if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi |
|
19 | 12 |
RUN echo "**** install PHP Composer ****\n" && \ |
20 | 13 |
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer |
21 |
COPY requirements.txt /requirements.txt |
|
22 |
RUN pip install -r /requirements.txt |
|
14 |
RUN rm -rf /usr/local/etc/php/conf.d/docker-php-ext-igbinary.ini; |
|
15 |
RUN rm -fr /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini; |
|
16 |
RUN { \ |
|
17 |
echo '[xdebug]'; \ |
|
18 |
echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)"; \ |
|
19 |
echo 'xdebug.remote_enable = 1'; \ |
|
20 |
echo 'xdebug.remote_port = 9001'; \ |
|
21 |
echo 'xdebug.remote_autostart = 1'; \ |
|
22 |
echo 'xdebug.remote_connect_back = 0'; \ |
|
23 |
echo 'xdebug.remote_host = localhost'; \ |
|
24 |
echo 'xdebug.idekey = VSCODE'; \ |
|
25 |
echo 'xdebug.remote_log=/var/www/symfony/xdebug/xdebug.log'; \ |
|
26 |
} > /usr/local/etc/php/conf.d/php-config.ini |
docker/php-fpm/dev/xdebug.ini | ||
---|---|---|
1 | 1 |
[XDebug] |
2 | 2 |
xdebug.remote_enable=1 |
3 | 3 |
xdebug.remote_autostart=1 |
4 |
xdebug.remote_handler=dbgp |
|
5 |
xdebug.remote_port=9000 |
|
6 |
xdebug.remote_connect_back=0 |
|
4 |
xdebug.remote_port=9001 |
|
5 |
xdebug.remote_connect_back=1 |
modules/crawler/.devcontainer/devcontainer.json | ||
---|---|---|
8 | 8 |
"service": "crawler", |
9 | 9 |
"shutdownAction": "stopCompose", |
10 | 10 |
"dockerComposeFile": ["../../../docker-compose.yml", "../../../docker-compose-dev.yml"], |
11 |
"mounts":["source=vscode-extensions-php,target=/src/.vscode-server/extensions,type=volume"]
|
|
11 |
"mounts":["source=vscode-extensions-python,target=/src/.vscode-server/extensions,type=volume"]
|
|
12 | 12 |
} |
website/.devcontainer/devcontainer.json | ||
---|---|---|
5 | 5 |
"ms-python.python", |
6 | 6 |
], |
7 | 7 |
"workspaceFolder": "/var/www/symfony", |
8 |
"build": {
|
|
9 |
"context": ".",
|
|
10 |
"dockerfile": "../../build/php-fpm/dev/Dockerfile"
|
|
11 |
} |
|
8 |
"service": "php-fpm",
|
|
9 |
"dockerComposeFile": ["../../docker-compose.yml", "../../docker-compose-dev.yml"],
|
|
10 |
"mounts":["source=vscode-extensions-php,target=/var/www/symfony/.vscode-server/extensions,type=volume"]
|
|
11 |
|
|
12 | 12 |
} |
website/.gitignore | ||
---|---|---|
7 | 7 |
/public/bundles/ |
8 | 8 |
/var/ |
9 | 9 |
/vendor/ |
10 |
.php_cs.cache |
|
10 | 11 |
###< symfony/framework-bundle ### |
11 | 12 |
|
12 | 13 |
###> friendsofphp/php-cs-fixer ### |
website/src/Kernel.php | ||
---|---|---|
2 | 2 |
|
3 | 3 |
namespace App; |
4 | 4 |
|
5 |
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
|
6 |
use Symfony\Component\Config\Loader\LoaderInterface; |
|
5 |
use const PHP_VERSION_ID; |
|
7 | 6 |
use Symfony\Component\Config\Resource\FileResource; |
8 |
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
9 |
use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
|
7 |
use Symfony\Component\Config\Loader\LoaderInterface; |
|
10 | 8 |
use Symfony\Component\Routing\RouteCollectionBuilder; |
9 |
use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
|
10 |
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
|
11 |
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
12 |
use function dirname; |
|
11 | 13 |
|
12 |
class Kernel extends BaseKernel |
|
13 |
{ |
|
14 |
class Kernel extends BaseKernel { |
|
14 | 15 |
use MicroKernelTrait; |
15 | 16 |
|
16 | 17 |
private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; |
17 | 18 |
|
18 |
public function registerBundles(): iterable |
|
19 |
{ |
|
19 |
public function registerBundles(): iterable { |
|
20 | 20 |
$contents = require $this->getProjectDir().'/config/bundles.php'; |
21 | 21 |
foreach ($contents as $class => $envs) { |
22 | 22 |
if ($envs[$this->environment] ?? $envs['all'] ?? false) { |
... | ... | |
25 | 25 |
} |
26 | 26 |
} |
27 | 27 |
|
28 |
public function getProjectDir(): string |
|
29 |
{ |
|
30 |
return \dirname(__DIR__); |
|
28 |
public function getProjectDir(): string { |
|
29 |
return dirname(__DIR__); |
|
31 | 30 |
} |
32 | 31 |
|
33 |
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void |
|
34 |
{ |
|
32 |
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { |
|
35 | 33 |
$container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php')); |
36 |
$container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug);
|
|
34 |
$container->setParameter('container.dumper.inline_class_loader', PHP_VERSION_ID < 70400 || $this->debug); |
|
37 | 35 |
$container->setParameter('container.dumper.inline_factories', true); |
38 | 36 |
$confDir = $this->getProjectDir().'/config'; |
39 | 37 |
|
... | ... | |
43 | 41 |
$loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob'); |
44 | 42 |
} |
45 | 43 |
|
46 |
protected function configureRoutes(RouteCollectionBuilder $routes): void |
|
47 |
{ |
|
44 |
protected function configureRoutes(RouteCollectionBuilder $routes): void { |
|
48 | 45 |
$confDir = $this->getProjectDir().'/config'; |
49 | 46 |
|
50 | 47 |
$routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob'); |
website/symfony.code-workspace | ||
---|---|---|
7 | 7 |
"settings": { |
8 | 8 |
"php.suggest.basic":false, |
9 | 9 |
"files.autoSave": "afterDelay", |
10 |
"php-cs-fixer.executablePath": "/var/www/symfony/vendor/bin/php-cs-fixer", |
|
11 |
"php-cs-fixer.config": ".php_cs;.php_cs.dist", |
|
12 |
"php-cs-fixer.onsave": true |
|
10 | 13 |
}, |
11 | 14 |
"extensions": { |
12 | 15 |
"recommendations": [ |
13 | 16 |
"vscode-icons-team.vscode-icons", |
14 | 17 |
"felixfbecker.php-intellisense", |
15 |
"whatwedo.twig" |
|
18 |
"whatwedo.twig", |
|
19 |
"felixfbecker.php-debug", |
|
20 |
"junstyle.php-cs-fixer" |
|
16 | 21 |
] |
17 | 22 |
}, |
18 | 23 |
"tasks": { |
19 | 24 |
"version": "2.0.0", |
20 | 25 |
"tasks": [{ |
21 |
"label": "PHP Linter", |
|
26 |
"label": "PHP Linter (DOCKER SERVICE)",
|
|
22 | 27 |
"command": "docker-compose", |
23 |
"args": ["exec", "php-fpm", "/var/www/symfony/vendor/bin/php-cs-fixer","fix", "--dry-run", "--config", "/var/www/symfony/.php_cs", "--stop-on-violation", "--using-cache=no"],
|
|
28 |
"args": ["exec", "php-fpm", "./vendor/bin/php-cs-fixer", "fix", "/var/www/symfony/src", "--dry-run", "--config", "/var/www/symfony/.php_cs", "--stop-on-violation", "--using-cache=no"],
|
|
24 | 29 |
"windows":{ |
25 | 30 |
"command": "docker-compose", |
26 |
"args": ["exec", "php-fpm", "/var/www/symfony/vendor/bin/php-cs-fixer", "fix", "--dry-run", "--config", "/var/www/symfony/.php_cs", "--stop-on-violation", "--using-cache=no"],
|
|
31 |
"args": ["exec", "php-fpm","./vendor/bin/php-cs-fixer", "fix", "/var/www/symfony/src", "--dry-run", "--config", "/var/www/symfony/.php_cs", "--stop-on-violation", "--using-cache=no"],
|
|
27 | 32 |
} |
28 | 33 |
}, |
29 | 34 |
{ |
30 |
"label": "Format", |
|
35 |
"label": "Format (DOCKER SERVICE)", |
|
36 |
"command": "docker-compose", |
|
37 |
"args": ["exec", "php-fpm", "/var/www/symfony/vendor/bin/php-cs-fixer", "fix", "/var/www/symfony/src", "--config", "/var/www/symfony/.php_cs", "--stop-on-violation"], |
|
38 |
"windows":{ |
|
39 |
"command": "docker-compose", |
|
40 |
"args": ["exec", "php-fpm", "/var/www/symfony/vendor/bin/php-cs-fixer", "fix", "/var/www/symfony/src", "--config", "/var/www/symfony/.php_cs", "--stop-on-violation"], |
|
41 |
} |
|
42 |
},{ |
|
43 |
"label": "PHP Linter", |
|
31 | 44 |
"command": "docker-compose", |
32 |
"args": ["exec", "php-fpm", "/var/www/symfony/vendor/bin/php-cs-fixer","fix", "--config", "/var/www/symfony/.php_cs", "--stop-on-violation"],
|
|
45 |
"args": ["exec", "php-fpm", "./vendor/bin/php-cs-fixer", "fix", "/var/www/symfony/src", "--dry-run", "--config", "/var/www/symfony/.php_cs", "--stop-on-violation", "--using-cache=no"],
|
|
33 | 46 |
"windows":{ |
34 | 47 |
"command": "docker-compose", |
35 |
"args": ["exec", "php-fpm", "/var/www/symfony/vendor/bin/php-cs-fixer", "fix", "--config", "/var/www/symfony/.php_cs", "--stop-on-violation"], |
|
48 |
"args": ["exec", "php-fpm","./vendor/bin/php-cs-fixer", "fix", "/var/www/symfony/src", "--dry-run", "--config", "/var/www/symfony/.php_cs", "--stop-on-violation", "--using-cache=no"], |
|
49 |
} |
|
50 |
}, |
|
51 |
{ |
|
52 |
"label": "Format", |
|
53 |
"command": "./vendor/bin/php-cs-fixer", |
|
54 |
"args": ["fix", "/var/www/symfony/src", "--config", "/var/www/symfony/.php_cs", "--stop-on-violation"], |
|
55 |
"windows":{ |
|
56 |
"command": "./vendor/bin/php-cs-fixer", |
|
57 |
"args": ["fix", "/var/www/symfony/src", "--config", "/var/www/symfony/.php_cs", "--stop-on-violation"], |
|
36 | 58 |
} |
37 | 59 |
}] |
38 | 60 |
}, |
39 | 61 |
"launch": { |
40 |
"configurations": [{ |
|
62 |
"configurations": [ |
|
63 |
{ |
|
41 | 64 |
"name": "Listen for XDebug", |
42 | 65 |
"type": "php", |
43 |
"request": "launch", |
|
44 |
"port": 9000 |
|
66 |
"request": "launch", |
|
67 |
"log": true, |
|
68 |
"pathMappings": { |
|
69 |
"/var/www/symfony": "${workspaceFolder}/" |
|
70 |
}, |
|
71 |
"port": 9001 |
|
45 | 72 |
}] |
46 | 73 |
} |
47 | 74 |
} |
Také k dispozici: Unified diff
debuger for php works