Skip to content

Commit c0756c2

Browse files
authored
Merge pull request #1328 from andersonav/master
Ambiente docker e parâmetro para validação na assinatura
2 parents d908d17 + 432f3c5 commit c0756c2

4 files changed

Lines changed: 59 additions & 2 deletions

File tree

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
services:
2+
app:
3+
build:
4+
context: .
5+
dockerfile: docker/php/Dockerfile
6+
args:
7+
USER_ID: ${UID:-1000}
8+
GROUP_ID: ${GID:-1000}
9+
container_name: sped-nfe-dev
10+
working_dir: /var/www/sped-nfe
11+
volumes:
12+
- ./:/var/www/sped-nfe
13+
- composer-cache:/tmp/composer/cache
14+
- ./docker/php/conf.d/custom.ini:/usr/local/etc/php/conf.d/99-custom.ini:ro
15+
tty: true
16+
stdin_open: true
17+
command: bash
18+
19+
volumes:
20+
composer-cache:

docker/php/Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM php:8.3-cli
2+
3+
ARG USER_ID=1000
4+
ARG GROUP_ID=1000
5+
6+
ENV COMPOSER_ALLOW_SUPERUSER=1
7+
ENV COMPOSER_HOME=/tmp/composer
8+
9+
RUN apt-get update && apt-get install -y --no-install-recommends \
10+
git \
11+
unzip \
12+
zip \
13+
libxml2-dev \
14+
libzip-dev \
15+
libcurl4-openssl-dev \
16+
&& docker-php-ext-install -j"$(nproc)" \
17+
dom \
18+
simplexml \
19+
soap \
20+
zip \
21+
&& rm -rf /var/lib/apt/lists/*
22+
23+
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
24+
25+
RUN groupadd -g "${GROUP_ID}" devuser \
26+
&& useradd -m -u "${USER_ID}" -g devuser -s /bin/bash devuser
27+
28+
WORKDIR /var/www/sped-nfe
29+
30+
USER devuser
31+
32+
CMD ["bash"]

docker/php/conf.d/custom.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
memory_limit = 512M
2+
max_execution_time = 120

src/Common/Tools.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ public function validKeyByUF(string $chave): string
364364
* @return string signed NFe xml
365365
* @throws RuntimeException
366366
*/
367-
public function signNFe(string $xml): string
367+
public function signNFe(string $xml, int $validXSD = 1): string
368368
{
369369
if (empty($xml)) {
370370
throw new InvalidArgumentException('O argumento xml passado para ser assinado está vazio.');
@@ -392,7 +392,10 @@ public function signNFe(string $xml): string
392392
$signed = $this->addQRCode($dom);
393393
}
394394
//exception will be throw if NFe is not valid
395-
$this->isValid($this->versao, $signed, 'nfe');
395+
if ($validXSD == 1) {
396+
$this->isValid($this->versao, $signed, 'nfe');
397+
}
398+
396399
return $signed;
397400
}
398401

0 commit comments

Comments
 (0)