Skip to content

Commit

Permalink
Merge pull request #2 from guenbakku/upgrade-dependencies
Browse files Browse the repository at this point in the history
Upgrade dependencies
  • Loading branch information
guenbakku authored Jun 19, 2024
2 parents aa80a4d + da46e9c commit 032fe36
Show file tree
Hide file tree
Showing 17 changed files with 989 additions and 700 deletions.
15 changes: 15 additions & 0 deletions .docker/php/000-default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<VirtualHost *:80>

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/webroot

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /var/www/html/webroot>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

</VirtualHost>
25 changes: 25 additions & 0 deletions .docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM php:7.2-apache

LABEL author="guenbakku"

# Install CakePHP required extensions
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libicu-dev \
libxrender1 \
libfontconfig \
&& docker-php-ext-install -j$(nproc) intl \
&& docker-php-ext-install -j$(nproc) pdo_mysql \
&& pecl install xdebug-3.1.5 \
&& docker-php-ext-enable xdebug

# Install zip & git (Required for composer install)
RUN apt-get install -y git zip

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

# Enable apache rewrite module
RUN ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
4 changes: 4 additions & 0 deletions .docker/php/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[xdebug]
zend_extension="xdebug.so"
xdebug.mode=develop,debug,coverage
xdebug.start_with_request = yes
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.bat]
end_of_line = crlf

[*.yml]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/vendors/*
/tests/Coverage/*
/vendors
/vendor
/tests/Coverage
.phpunit.result.cache
12 changes: 12 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Development

```bash
# 1. Build docker image for developing (first time only)
$ docker-compose build

# 2. Composer installing (first time only)
$ docker-compose run --rm php composer install

# 3. Execute phpunit
$ docker-compose run --rm php vendor/bin/phpunit
```
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Cakepdf

CakePHP plugin for converting HTML to PDF.
This plugin is compatible with CakePHP 2.x and CakePHP 3.x.
This plugin could not be made without awesome library [Snappy](https://github.com/KnpLabs/snappy).
Thankful to the authors of library Snappy.
Easily generate PDFs from your HTML content.

This versatile tool can be used as:

* A CakePHP plugin: Seamlessly integrate PDF generation into your CakePHP 2.x and above applications.
* A standalone library: Use it independently outside of CakePHP for maximum flexibility.

Powered by Snappy (https://github.com/KnpLabs/snappy)
I want to give a big thanks to the creators of the fantastic Snappy library, which makes this functionality possible.

## Installation

Expand All @@ -25,31 +30,31 @@ use Guenbakku\Cakepdf\Pdf;
// wkhtmltopdf binary which is installed as composer dependencies.
// So following setup also automatically set wkhtmltopdf binary's path
// corresponding to current processor's structure (32 or 64 bit).
$Pdf = new Pdf();
$pdf = new Pdf();

// Add html to render to pdf.
// Break page will be inserted automatically by wkhtmltopdf.
$html = '<p>Long html for long pdf</p>';
$Pdf->add($html);
$pdf->add($html);

// Add each html as a seperated pdf page.
$page = '<p>Page</p>';
$Pdf->addPage($page)
$pdf->addPage($page)
->addPage($page);

// Render output to display in browser.
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="file.pdf"');
$result = $Pdf->render();
$result = $pdf->render();
echo $result;

// Or render output to pdf file.
$output = '/tmp/cakepdf.pdf';
$Pdf->render($output);
$pdf->render($output);

// Set options for wkhtmltopdf.
// Basically same with Snappy's interface.
$Pdf = new Pdf();
$Pdf->setOption('page-size', 'A4')
$pdf = new Pdf();
$pdf->setOption('page-size', 'A4')
->setOption('orientation', 'Landscape');
```
15 changes: 6 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,17 @@
}
],
"require": {
"php": ">=5.6",
"knplabs/knp-snappy": "^0.5.0",
"h4cc/wkhtmltopdf-i386": "^0.12.3",
"h4cc/wkhtmltopdf-amd64": "^0.12.3"
"php": "^7.2",
"knplabs/knp-snappy": "1.4.x",
"h4cc/wkhtmltopdf-i386": "^0.12.4",
"h4cc/wkhtmltopdf-amd64": "^0.12.4"
},
"require-dev": {
"phpunit/phpunit": "^5.7|^6.0"
"phpunit/phpunit": "^8.5.38"
},
"autoload": {
"psr-4": {
"Guenbakku\\Cakepdf\\": "src"
}
},
"config": {
"vendor-dir": "vendors/"
}
}
}
Loading

0 comments on commit 032fe36

Please sign in to comment.