"один продукт может принадлежать к 0:N категорий"
version: '2'
services:
nginx:
build: ./docker/nginx
ports:
- "80:80"
links:
- php
volumes:
- ./docker/nginx/http.conf:/etc/nginx/conf.d/http.conf
- ./docker/nginx/site.conf:/etc/nginx/sites-enabled/site.conf
volumes_from:
- php
command: 'nginx -g "daemon off;"'
php:
build: ./docker/php
volumes:
- .:/src
- ./docker/php/php-cli.ini:/etc/php/7.0/cli/conf.d/php-cli.ini
- ./docker/php/php-fpm.ini:/etc/php/7.0/fpm/conf.d/php-fpm.ini
- ./docker/php/pool.conf:/etc/php/7.0/fpm/pool.d/www.conf
command: 'php-fpm7.0 -F'
links:
- db
- cache
environment:
SYMFONY__DB__DRIVER: pdo_pgsql
SYMFONY__DB__HOST: db
SYMFONY__DB__PORT: 5432
SYMFONY__DB__NAME: dbname
SYMFONY__DB__USER: dbuser
SYMFONY__DB__PASSWORD: dbpassword
db:
image: "postgres:latest"
environment:
POSTGRES_DB: dbname
POSTGRES_USER: dbuser
POSTGRES_PASSWORD: dbpassword
cache:
image: "redis:latest"
command: redis-server --appendonly yes
FROM ubuntu:16.04
RUN apt-get update \
&& apt-get install -y nginx
access_log /dev/stdout;
error_log /dev/stderr;
server {
listen 80;
server_name example.dev;
root /src/web;
index index.php index.html;
location / {
try_files $uri /app_dev.php$is_args$args;
}
location ~ ^/(app_dev|config)\.php(/|$) {
include fastcgi.conf;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_pass php:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
location ~ \.php$ {
return 404;
}
}
FROM ubuntu:16.04
ENV PHP_PACKAGES \
php7.0-fpm \
php7.0-cli \
php7.0-readline \
php7.0-pgsql \
php7.0-mcrypt \
php7.0-xml
RUN apt-get update \
&& apt-get install -y $PHP_PACKAGES
RUN usermod -u 1000 www-data
error_reporting = -1
display_errors = On
log_errors = Off
html_errors = Off
error_reporting = -1
display_errors = On
log_errors = Off
html_errors = On
cgi.fix_pathinfo = 0
pid = /var/run/php.pid
[www]
user = www-data
group = www-data
listen = 0.0.0.0:9000
pm = dynamic
pm.max_children = 20
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
clear_env = no
catch_workers_output = yes
docker cp file.sql.gz containername:/tmp/dump.sql.gz
docker exec -ti containername bash
gunzip -c /tmp/dump.sql.gz | psql -U username dbname
.pipe(twig({
namespaces: {
'VendorBundle': 'vendor/vendor-bundle/Resources/views/'
}
}))
Здесь только регуляркой или как?
function incrementNumberInString(str) {
for (let i = 0, iNum = -1; i < str.length; i++) {
if ('0123456789'.includes(str[i])) {
if (iNum === -1 && str[i - 1] === '[') {
iNum = i;
}
} else if (iNum !== -1 && str[i] === ']') {
return str.slice(0, iNum) + (Number(str.slice(iNum, i)) + 1) + str.slice(i);
} else {
iNum = -1;
}
}
return str;
}
str.replace(/(?<=\[)\d+(?=\])/, m => ++m)
// или
str.replace(/\[\d+\]/, m => '[' + (m.slice(1, -1) - -1) + ']')
// или
str.replace(/\[(\d+)\]/, (m, g1) => `[${-~g1}]`)
$arr = [
[
"answer_schema_id" => "1",
"content" => "odpowiedz 1",
"locale" => "pl",
"points" => "3",
"answerKey" => "1",
"answerElementOrder" => "1",
"image" => "5cd143beba821203428009.jpg",
], [
"answer_schema_id" => "1",
"content" => "answer 1",
"locale" => "en",
"points" => "3",
"answerKey" => "1",
"answerElementOrder" => "1",
"image" => "5cd143beba821203428009.jpg",
], [
"answer_schema_id" => "2",
"content" => "answer 2",
"locale" => "en",
"points" => "2",
"answerKey" => "2",
"answerElementOrder" => "2",
"image" => "5cd143bebcdfc405126844.jpg",
], [
"answer_schema_id" => "2",
"content" => "odpowiedz 2",
"locale" => "pl",
"points" => "2",
"answerKey" => "2",
"answerElementOrder" => "2",
"image" => "5cd143bebcdfc405126844.jpg",
]
];
$result = [];
$ptr = [];
foreach ($arr as $el) {
if (!isset($ptr[$el['answer_schema_id']])) {
$res[] = [
"answer_schema_id" => $el['answer_schema_id'],
"content" => [],
"points" => $el['points'],
"answerKey" => $el['answerKey'],
"answerElementOrder" => $el['answerElementOrder'],
"image" => $el['image']
];
$ptr[$el['answer_schema_id']] = count($res)-1;
}
$res[$ptr[$el['answer_schema_id']]]['content'][$el['locale']] = $el['content'];
}
var_dump($res);
array(2) {
[0] => array(6) {
["answer_schema_id"] => string(1) "1"
["content"] => array(2) {
["pl"] => string(11) "odpowiedz 1"
["en"] =>string(8) "answer 1"
}
["points"] => string(1) "3"
["answerKey"] => string(1) "1"
["answerElementOrder"] => string(1) "1"
["image"] => string(26) "5cd143beba821203428009.jpg"
}
[1] => array(6) {
["answer_schema_id"] => string(1) "2"
["content"] => array(2) {
["en"] => string(8) "answer 2"
["pl"] => string(11) "odpowiedz 2"
}
["points"] => string(1) "2"
["answerKey"] => string(1) "2"
["answerElementOrder"] => string(1) "2"
["image"] => string(26) "5cd143bebcdfc405126844.jpg"
}
}
$(key).css('background-color', 'green');