Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/pro 1750/docker update #145

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5d11078
feat(BE-1914): fork and adapt the library
calinblaga May 25, 2021
2781a65
feat(BE-1914): makes it php 7.4 compatible
calinblaga May 25, 2021
459abf1
feat(BE-1914): introduce laminas
haeber May 27, 2021
7a548a5
Merge pull request #2 from jobcloud/feat/BE-1914/introduce-laminas
haeber May 28, 2021
36ee83c
Merge pull request #1 from jobcloud/feat/BE-1914/fork-and-adapt
haeber May 28, 2021
55fedd7
fix(BE-2482): replace curly braces for compatibility with newer PHP v…
haeber Jan 20, 2022
1229b46
Merge pull request #3 from jobcloud/fix/BE-2482/replace-curly-braces
haeber Jan 24, 2022
080ad84
feat(BE-2692): adjustments
calinblaga Jun 27, 2022
693c589
Merge pull request #4 from jobcloud/feat/BE-2692/adjustments
calinblaga Jul 14, 2022
6d154e8
feat(FIAP-59): update lib to support php 8.1
tomicgoran Apr 20, 2023
8f8af3e
feat(FIAP-59): get rid of laminas dependencies which are not used and…
tomicgoran Apr 24, 2023
2925f45
feat(FIAP-56): cleanup
tomicgoran Apr 25, 2023
3182975
Merge pull request #5 from jobcloud/feat/FIAP-59/php-8.1-upgrade
haeber May 24, 2023
63fed4c
feat(FIAP-197): fix deprecations WIP
tomicgoran Jun 1, 2023
7335c00
feat(FIAP-197): fix deprecations WIP#2
tomicgoran Jun 1, 2023
6e4ca1b
feat(FIAP-197): updated zendpdf
tomicgoran Jun 2, 2023
8704dc6
feat(FIAP-197): prefer-stable
tomicgoran Jun 2, 2023
d501c4b
feat(FIAP-197): use tagged ver of zendpdf
tomicgoran Jun 2, 2023
cd8fbe4
feat(FIAP-197): use alpine and update composer
haeber Jun 5, 2023
946b9b7
Merge pull request #6 from jobcloud/feat/FIAP-197/fix-deprecations
haeber Jun 5, 2023
c74b063
feat(PRO-684): solve PHP 8.1 deprecation
haeber Jun 5, 2023
7addcc4
fix(PRO-698): fix null on strtolower PHP 8.1 deprecation
haeber Jun 7, 2023
60fc4ad
Merge pull request #7 from jobcloud/fix/PRO-698/strtolower-with-null-…
haeber Jun 7, 2023
c262967
fix(PRO-698): PHP 8.1 deprecation fixes - null on substr
haeber Jun 8, 2023
539d34f
Merge pull request #8 from jobcloud/fix/PRO-698/php81-deprecation-fixes
haeber Jun 8, 2023
1225886
fix(PRO-698): PHP 8.1 deprecation fixes - null on preg_split; clean c…
haeber Jun 8, 2023
67097c5
Merge pull request #9 from jobcloud/fix/PRO-698/php81-deprecation-fixes
haeber Jun 9, 2023
8451636
chore(PRO-1750): php docker update
stevan-tosic Apr 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @jobcloud/find-and-apply-team-be @jobcloud/profile-team-be
39 changes: 25 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
{
"name": "psliwa/php-pdf",
"name": "jobcloud/psliwa-php-pdf",
"description": "Pdf and graphic files generator library for PHP.",
"keywords": ["PDF", "PHPPdf"],
"keywords": [
"PDF",
"PHPPdf"
],
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Piotr Śliwa",
"name": "Piotr Śliwa",
"homepage": "http://ohey.pl",
"email": "[email protected]"
"email": "[email protected]"
}
],
"repositories": [
{"type": "vcs", "no-api": true, "url": "[email protected]:jobcloud/zendpdf.git"}
],
"require": {
"zendframework/zendpdf": "~2.0.0",
"zendframework/zend-cache": "^2.0"
"php": "^8.1",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-xmlreader": "*",
"jobcloud/zendpdf": "^2.0.3"
},
"require-dev": {
"zendframework/zend-barcode": "^2.0",
"zendframework/zend-validator": "^2.0",
"imagine/Imagine": ">=0.2.0,<0.6.0",
"phpunit/phpunit": ">=4,<5.4.0"
"imagine/imagine": ">=0.2.0,<0.6.0",
"phpunit/phpunit": "^8.5.33"
},
"prefer-stable": true,
"minimum-stability": "dev",
"suggest": {
"zendframework/zend-barcode": "If you want to use barcodes",
"zendframework/zend-validator": "If you want to use barcodes (required by zend-barcode)",
"imagine/Imagine": "If you want to use image generating (required version: >=v0.2.6)"
"imagine/imagine": "If you want to use image generating (required version: >=v0.2.6)"
},
"autoload": {
"psr-0": { "PHPPdf": "lib/", "Imagine": "lib/" }
"psr-0": {
"PHPPdf": "lib/",
"Imagine": "lib/"
}
}
}
3 changes: 3 additions & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
COMPOSE_PROJECT_NAME=jobcloud-phppdf
XDEBUG_REMOTE_HOST=localhost
#XDEBUG_REMOTE_HOST=docker.for.mac.localhost
25 changes: 25 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3.9'
services:
php:
container_name: jobcloud-phppdf-php
hostname: jobcloud-phppdf-php
build:
dockerfile: php/Dockerfile
context: ./
args:
USER_ID: ${USER_ID}
ports:
- '8080:80'
tty: true
volumes:
- ../:/var/www/html
- ~/.bash_aliases:/home/www-data/.bash_aliases:rw
- ~/.bash_history:/home/www-data/.bash_history:rw
secrets:
- ssh_host_key
environment:
XDEBUG_CONFIG: remote_host=${XDEBUG_REMOTE_HOST}
PHP_IDE_CONFIG: serverName=php
secrets:
ssh_host_key:
file: ~/.ssh/id_rsa
37 changes: 37 additions & 0 deletions docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM php:8.1-alpine3.19

ARG USER_ID

# PHP: Copy configuration files & remove dist files
RUN mkdir /phpIni
COPY php/files/bin/ /usr/local/bin/

# SYS: Install required packages
RUN apk --no-cache upgrade && \
apk --no-cache add bash git sudo openssh autoconf gcc g++ make gettext sudo shadow

RUN if [ -n "$USER_ID" ] && [ "$USER_ID" -lt 60001 ]; then \
usermod -u ${USER_ID} -o www-data; \
fi

# USER: set /bin/bash and allow www-data to become root
RUN usermod -s /bin/bash www-data && \
echo 'www-data ALL=(ALL) NOPASSWD: ALL' > '/etc/sudoers.d/www-data'

# USER: copy home
COPY --chown=www-data:www-data php/files/user-home /home/www-data

# USER: add ssh key and fix permission of the ssh directory
RUN ln -s /run/secrets/ssh_host_key /home/www-data/.ssh/id_rsa && \
chmod 700 /home/www-data/.ssh && \
chmod 400 /home/www-data/.ssh/config

# PHP: Install php extensions
RUN pecl channel-update pecl.php.net

# COMPOSER: install binary
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

USER www-data

WORKDIR /var/www/html
12 changes: 12 additions & 0 deletions docker/php/files/bin/php-ext-disable
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

if [ $# -eq 0 ]
then
echo "Please pass a php module name"
exit
fi

for phpmod in "$@"
do
rm -f /usr/local/etc/php/conf.d/*$phpmod*.ini
done
20 changes: 20 additions & 0 deletions docker/php/files/bin/php-ext-enable
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

if [[ ${#} -eq 0 ]] ; then
echo -e "\\nPHP module name required!\\n"
exit 1
fi

for phpmod in "${@}" ; do

files=($(find /phpIni -type f -iname "*${phpmod}*.ini" -exec ls -1 '{}' +))

for i in "${files[@]}" ; do
ln -s "${i}" /usr/local/etc/php/conf.d
done

if [[ ${#files[@]} -eq 0 ]] ; then
docker-php-ext-enable "${phpmod}"
fi

done
7 changes: 7 additions & 0 deletions docker/php/files/user-home/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
alias cls='printf "\033c"'

export PS1='\[\e[1;32m\]\h\[\e[0m\] \[\e[1;37m\]\w\[\e[0m\] \[\e[1;32m\]\u\[\e[0m\] \[\e[1;37m\]\$\[\e[0m\] '

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
4 changes: 4 additions & 0 deletions docker/php/files/user-home/.ssh/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Host *
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
IdentityFile /run/secrets/ssh_host_key
16 changes: 8 additions & 8 deletions lib/PHPPdf/Cache/CacheImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

namespace PHPPdf\Cache;

use Zend\Cache\StorageFactory;
use Zend\Cache\Storage\StorageInterface;
use Laminas\Cache\StorageFactory;
use Laminas\Cache\Storage\StorageInterface;
use PHPPdf\Exception\RuntimeException;

/**
Expand All @@ -25,7 +25,7 @@ class CacheImpl implements Cache
const ENGINE_FILESYSTEM = 'Filesystem';

/**
* @var Zend\Cache\Storage\Adapter
* @var Laminas\Cache\Storage\Adapter
*/
private $adapter;

Expand Down Expand Up @@ -93,7 +93,7 @@ public function load($id)

return $data;
}
catch(\Zend\Cache\Exception\ExceptionInterface $e)
catch(\Laminas\Cache\Exception\ExceptionInterface $e)
{
$this->wrapLowLevelException($e, __METHOD__);
}
Expand All @@ -110,7 +110,7 @@ public function test($id)
{
return $this->adapter->hasItem($id);
}
catch(\Zend\Cache\Exception\ExceptionInterface $e)
catch(\Laminas\Cache\Exception\ExceptionInterface $e)
{
$this->wrapLowLevelException($e, __METHOD__);
}
Expand All @@ -133,7 +133,7 @@ public function save($data, $id)

return $this->adapter->setItem($id, $data);
}
catch(\Zend\Cache\Exception\ExceptionInterface $e)
catch(\Laminas\Cache\Exception\ExceptionInterface $e)
{
$this->wrapLowLevelException($e, __METHOD__);
}
Expand All @@ -145,9 +145,9 @@ public function remove($id)
{
return $this->adapter->removeItem($id);
}
catch(\Zend\Cache\Exception\ExceptionInterface $e)
catch(\Laminas\Cache\Exception\ExceptionInterface $e)
{
$this->wrapLowLevelException($e, __METHOD__);
}
}
}
}
2 changes: 1 addition & 1 deletion lib/PHPPdf/Core/AbstractUnitConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract protected function convertPtUnit($value);

public function convertPercentageValue($percent, $value)
{
if(strpos($percent, '%') !== false)
if(null !== $percent && str_contains($percent, '%'))
{
$percent = (double) $percent;
$percent = $value*$percent / 100;
Expand Down
7 changes: 5 additions & 2 deletions lib/PHPPdf/Core/AttributeBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

namespace PHPPdf\Core;

use ReturnTypeWillChange;

/**
* Bag of attributes
*
* @author Piotr Śliwa <[email protected]>
*/
class AttributeBag implements \Countable, \Serializable
class AttributeBag implements \Countable
{
private $elements = array();

Expand All @@ -39,6 +41,7 @@ public function add($name, $value)
return $this;
}

#[ReturnTypeWillChange]
public function count()
{
return count($this->elements);
Expand Down Expand Up @@ -92,4 +95,4 @@ public function unserialize($serialized)
{
$this->elements = \unserialize($serialized);
}
}
}
23 changes: 18 additions & 5 deletions lib/PHPPdf/Core/Boundary.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@

namespace PHPPdf\Core;

use PHPPdf\Exception\OutOfBoundsException;
use PHPPdf\Exception\BadMethodCallException;
use PHPPdf\Exception\InvalidArgumentException;
use PHPPdf\Exception\OutOfBoundsException;
use PHPPdf\Exception\BadMethodCallException;
use PHPPdf\Exception\InvalidArgumentException;
use PHPPdf\Exception\LogicException;

use ReturnTypeWillChange;

/**
* Set of ordered points whom determine boundary and shape of node element.
*
* @author Piotr Śliwa <[email protected]>
*/
class Boundary implements \Countable, \Iterator, \ArrayAccess, \Serializable
class Boundary implements \Countable, \Iterator, \ArrayAccess
{
private $points = array();
private $numberOfPoints = 0;
Expand Down Expand Up @@ -169,11 +170,13 @@ private function getPointBetween(Point $point1, Point $point2)
/**
* @return integer Number of points in boundary
*/
#[ReturnTypeWillChange]
public function count()
{
return $this->numberOfPoints;
}

#[ReturnTypeWillChange]
public function current()
{
$points = $this->getPoints();
Expand All @@ -183,6 +186,8 @@ public function current()
/**
* @return array Array of Point objects
*/

#[ReturnTypeWillChange]
public function getPoints()
{
return $this->points;
Expand All @@ -193,21 +198,25 @@ public function getPoint($i)
return $this->offsetGet($i);
}

#[ReturnTypeWillChange]
public function key()
{
return $this->current;
}

#[ReturnTypeWillChange]
public function next()
{
$this->current++;
}

#[ReturnTypeWillChange]
public function rewind()
{
$this->current = 0;
}

#[ReturnTypeWillChange]
public function valid()
{
$points = $this->getPoints();
Expand Down Expand Up @@ -314,11 +323,13 @@ public function isClosed()
return $this->closed;
}

#[ReturnTypeWillChange]
public function offsetExists($offset)
{
return (is_int($offset) && $offset < $this->numberOfPoints);
}

#[ReturnTypeWillChange]
public function offsetGet($offset)
{
if(!$this->offsetExists($offset))
Expand All @@ -329,11 +340,13 @@ public function offsetGet($offset)
return $this->points[$offset];
}

#[ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
throw new BadMethodCallException('You can not set point directly.');
}

#[ReturnTypeWillChange]
public function offsetUnset($offset)
{
throw new BadMethodCallException('You can not unset point directly.');
Expand Down
Loading