Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
fagundes committed Mar 30, 2016
2 parents 714b665 + 909d0df commit 580dd65
Show file tree
Hide file tree
Showing 18 changed files with 352 additions and 104 deletions.
21 changes: 17 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@ language: php
php:
- 5.5
- 5.6
- 7
- hhvm

env:
global:
- SITE_URL: https://fagundes.github.io/ZffHtml2pdf
- GH_USER_NAME: "Vinícius Fagundes"
- GH_USER_EMAIL: mvlacerda@gmail.com
- GH_REF: github.com/fagundes/ZffHtml2pdf.git
- secure: "rKwNZHEhMyYSLng7YPTuexNqCFGtBl2ju5jeZJjm506Qe/jLSghwrwYlxuYWhhBmCPHtslpbNCDPpd7QIfkhQN2ixqXxPHvHy2XpXaeRgnE92FMS3oBsL2UKeoPwzNuFAFFydM2/UT60/PI4MnYu7zvwuhqShZpyeo3moWKozCVtW7K783W2r3ZgjAVD4wV7+Q2eQAANgIFy+BrNxPdGhNG7wAML6b86HXq05kU3jH1I0qjfj7t2GtqBfBhQ2f+2MpBvz0Wn+JRGO7znjX5gohcjIE9Pf5s9PPgT868g3Vd21MCw9Td1zoLgPymYVFsg2XiD547UW1NC63L/hDxMcqoPj1QtV9/h9gj6Tt/2o7jmn0uzJBK4nDozDp1kNSRE2vNM8EiKPQWi9Ritop0aw0vQlZxZtfVcYkNuvaoCBu5D5Xpf4/3GsAG0X/S2lYcrMo8c0PZgq6ZNJbKQQa3sjNHbDfgebD4NJY+0ITPWTa9Yz7uNVwiS4Qkm0SDVrk9dGTnSp2GLBu12p3y8whAi87ofv5WSwBgfgOEuFyZkQY7t9zgVy8N8jGcnGMq0W1HZPq2ZYhB8LgbBFzzLEQJSUOBot1BcQ9ZfkVlwdUvoOSZWFBFdtxy9v9GiUBYymOaUegqu16R86dRfYuL5MW81bguIXtIiT3U+rPcYXvLfkM0="

matrix:
include:
- php: 5.5
env:
- EXECUTE_TEST_COVERALLS=true
- php: 5.6
env:
- EXECUTE_TEST_COVERALLS=true
- DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)"
- PATH="$HOME/.local/bin:$PATH"
allow_failures:
- php: 7
- php: hhvm

before_install:
Expand All @@ -26,6 +35,10 @@ install:
script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit ; fi

- if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then wget -O theme-installer.sh "https://raw.githubusercontent.com/zendframework/zf-mkdoc-theme/master/theme-installer.sh" ; chmod 755 theme-installer.sh ; ./theme-installer.sh ; fi

after_success:
- if [[ $DEPLOY_DOCS == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./zf-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; fi

after_script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls ; fi
81 changes: 17 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

Zff\Html2Pdf
===========

`Zff\Html2Pdf` module integrates [spipu/html2pdf](https://github.com/spipu/html2pdf) with Zend Framework.

[![Latest Unstable Version](https://img.shields.io/packagist/vpre/fagundes/zff-html2pdf.svg)](https://packagist.org/packages/fagundes/zff-html2pdf)
[![Build Status](https://travis-ci.org/fagundes/ZffHtml2pdf.svg?branch=develop)](https://travis-ci.org/fagundes/ZffHtml2pdf)
[![Coverage Status](https://coveralls.io/repos/fagundes/ZffHtml2pdf/badge.svg?branch=develop&service=github)](https://coveralls.io/github/fagundes/ZffHtml2pdf?branch=develop)
Expand All @@ -6,72 +12,19 @@
[![Build Status](https://travis-ci.org/fagundes/ZffHtml2pdf.svg?branch=0.5.0)](https://travis-ci.org/fagundes/ZffHtml2pdf)
[![Coverage Status](https://coveralls.io/repos/fagundes/ZffHtml2pdf/badge.svg?branch=0.5.0&service=github)](https://coveralls.io/github/fagundes/ZffHtml2pdf?branch=0.5.0)

[![Total Downloads](https://poser.pugx.org/fagundes/zff-html2pdf/downloads)](https://packagist.org/packages/fagundes/zff-html2pdf) [![License](https://poser.pugx.org/fagundes/zff-html2pdf/license)](https://packagist.org/packages/fagundes/zff-html2pdf)

Zff Html2Pdf for Zend Framework 2
===================================

`Zff\Html2Pdf` module integrates [HTML2PDF](https://github.com/spipu/html2pdf) with Zend Framework 2 easily.

## Installation

Installation of this module uses composer. For composer documentation, please refer to
[getcomposer.org](http://getcomposer.org/).

```bash
php composer.phar require fagundes/zff-html2pdf:0.*
```

Then add `Zff\\Html2Pdf` to your `config/application.config.php`.

Installation without composer is not officially supported and requires you to manually install all dependencies that are listed in composer.json

## Contribuing

If you want to help check the contribuing instructions [here](CONTRIBUTING.md).

## TODO

- [ ] Rewrite html2pdf examples using `Zff\Html2Pdf`
- [ ] Create a way to easily change params from HTML2PDF's constructor, called on `Html2PdfRenderer` class, on controller, view or config file.

## Usage

Controller Example: `AnyController.php`

```php
<?php

use Zff\Html2Pdf\View\Model\Html2PdfModel;

class AnyController
{

public function someAction()
{
//some logic here

return new Html2PdfModel([
'foo' => $foo,
'bar' => $bar
]);
}
- File issues at https://github.com/fagundes/ZffHtml2pdf/issues
- [Online documentation](https://fagundes.github.io/ZffHtml2pdf)
- [Documentation source files](doc/book/)

}
```
TODO List
---------

View Example: `some.phtml`
- [ ] Rewrite html2pdf examples using `Zff\Html2Pdf` (IN PROGRESS)
- [x] Create a way to easily change params from HTML2PDF's constructor, called on `Html2PdfRenderer` class, on controller, view or config file.

```php
<!-- Regular HTML -->
<div class="container">
<h2>The header</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus eu metus sed lacus ultrices pharetra a vitae massa.
</p>
</div>
```
Contribuing
-----------

## Documentation
You can help opening new issues (or solving) and creating Pull Requests (PR).

Check for examples and HTML / CSS support at [html2pdf.fr](http://html2pdf.fr/) and [github.com/spipu/html2pdf](https://github.com/spipu/html2pdf).
Check [detailed instructions](docs\contribuing.md) for contributions.
6 changes: 6 additions & 0 deletions config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DO NOT EDIT THE CONFIG FILES DIRECTLY IN THIS DIRECTORY!
--------------------------------------------------------

Copy the dist file into your `./config/autoload` directory. Remove the .dist part.

Or you can copy it content into your `./module/MyExampleModule/config/module.config.php` file.
9 changes: 6 additions & 3 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@

namespace Zff\Html2Pdf;

use Zend\ServiceManager\Factory\InvokableFactory;

return [
'view_manager' => [
'view_manager' => [
'strategies' => [
'ViewHtml2PdfStrategy',
],
],
'service_manager' => [
'factories' => [
'ViewHtml2PdfStrategy' => 'Zff\Html2Pdf\Mvc\Service\ViewHtml2PdfStrategyFactory',
'factories' => [
Html2PdfFactory::class => InvokableFactory::class,
'ViewHtml2PdfStrategy' => Mvc\Service\ViewHtml2PdfStrategyFactory::class,
],
],
];
20 changes: 20 additions & 0 deletions config/zffhtml2pdf.global.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* ZffHtml2Pdf Configuration
*
* If you have a ./config/autoload/ directory set up for your project, you can
* drop this config file in it and change the values as you wish.
*/
return [
'zff-html2pdf' => [
//default factory options
'options' => [
'orientation' => 'P',
'format' => 'A4',
'lang' => 'en',
'unicode' => true,
'encoding' => 'UTF-8',
'margins' => [0, 0, 0, 0],
],
],
];
21 changes: 21 additions & 0 deletions doc/book/configuring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Configuring html2pdf constructor

Optionally, you can change the default values for html2pdf
constructor by adding this configuration to your `./config/autoload/global.php`.

```php
<?php
return [
'zff-html2pdf' => [
//HTML2PDF factory options
'options' => [
'orientation' => 'P',
'format' => 'A4',
'lang' => 'en',
'unicode' => true,
'encoding' => 'UTF-8',
'margins' => [0, 0, 0, 0],
],
],
];
```
17 changes: 8 additions & 9 deletions CONTRIBUTING.md → doc/book/contribuing.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
Contribuing
=============================
# Contribuing

If you want to help this project, you should read this instruction to know better how to do that.

There are a lot to do here: documentation, unit tests, new features, suggestions, report issues and solve issues.
Btw, you can check our [issues](https://github.com/fagundes/ZffHtml2pdf/issues) list.

## Composer
## 1. Composer

The [composer](http://getcomposer.org) is a manager dependency tool for PHP projects. With it is possible to install
all libs a software need and with a single command.

## Code style
## 2. Code style

Any code change MUST follow [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md).

The [PHP_CodeSniffer](https://github.com/squizlabs/php_codesniffer) is used to help us detect and fix violations of a defined set of coding standards.

CodeSniffer can be installed using composer, and it's a dev dependency to this project.

## git-flow
## 3. git-flow

[git-flow](https://github.com/nvie/gitflow) is a very useful tool to help improve your development using branchs.

The original post which inspired this git extension can be readed [here](http://nvie.com/posts/a-successful-git-branching-model).

## Good to go!
## 4. Good to go!

Are you ready to make some code? Great! Follow these steps:

1. Do a [fork](https://help.github.com/articles/fork-a-repo) and do a local clone of your fork;
- Resolve dependencies using composer ```composer install```;
- Initialize the git-flow (```git flow init -d```);
- Create your branch
2. Resolve dependencies using composer ```composer install```;
3. Initialize the git-flow (```git flow init -d```);
4. Create your branch
* If you want to create a new feature you should execute the commmand
```git flow feature start $feature```, where $feature
is an name id for your new feature;
Expand Down
7 changes: 7 additions & 0 deletions doc/book/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Examples

## Coming Soon

We gonna create here a full list of example written for ZF2.

For now, check for examples and HTML / CSS support at [html2pdf.fr](http://html2pdf.fr/) and [github.com/spipu/html2pdf](https://github.com/spipu/html2pdf).
9 changes: 9 additions & 0 deletions doc/book/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="container">
<div class="jumbotron">
<h1>zff-html2pdf</h1>

<p>Zff\Html2Pdf module integrates <a href="https://github.com/spipu/html2pdf">spipu/html2pdf</a> with Zend Framework</p>

<pre><code class="language-bash">$ composer require fagundes/zff-html2pdf:0.*</code></pre>
</div>
</div>
1 change: 1 addition & 0 deletions doc/book/index.md
62 changes: 62 additions & 0 deletions doc/book/quick-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Quick Start

The Zff Html2pdf is a simple wrapper to easily integrates the [spipu/html2pdf](https://github.com/spipu/html2pdf) library to Zend Framework.
It creates a Html2PdfStrategy to get a ordinary `.phtml` template and returns it as a `.pdf` file.

## 1. Install Zff\Html2pdf


Installation of this module uses composer. For composer documentation, please refer to
[getcomposer.org](http://getcomposer.org/).

```bash
php composer.phar require fagundes/zff-html2pdf:0.*
```

Then add `Zff\\Html2Pdf` to your `config/application.config.php`.

Installation without composer is not officially supported and requires you to manually install all dependencies that are listed in composer.json

## 2. Usage

### 2.1. Ready to Go

This module comes ready to go. You need to return a `Html2PdfModel` in your controller action, instead of a `ViewModel` or an `array`.
And create your view template `.phtml` for that action. And that's it, your view will be rendered as a `.pdf` file!

### 2.2. Simple Example

Controller: `AnyController.php`

```php
<?php

use Zff\Html2Pdf\View\Model\Html2PdfModel;
`Html2PdfModel
class AnyController
{

public function someAction()
{
//some logic here

return new Html2PdfModel([
'foo' => $foo,
'bar' => $bar
]);
}

}
```

View: `some.phtml`

```php
<!-- Regular HTML -->
<div class="container">
<h2>The header</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus eu metus sed lacus ultrices pharetra a vitae massa.
</p>
</div>
```
13 changes: 13 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
docs_dir: doc/book
site_dir: doc/html
pages:
- index.md
- 'Quick Start': quick-start.md
- Reference:
- 'Configuring the html2pdf constructor': configuring.md
- Examples: examples.md
- Contribuing: contribuing.md
site_name: Zff\Html2pdf
site_description: 'Zff\Html2pdf : Module for Zend Framework'
repo_url: 'https://github.com/fagundes/zff-html2pdf'
copyright: 'Copyright (c) 2016 <a href="http://www.viniciusfagundes.com/">Vinícius Fagundes</a>'

0 comments on commit 580dd65

Please sign in to comment.