Skip to content

Commit cc66c90

Browse files
authored
Merge pull request #279 from KnpLabs/remove-non-lts-symfony-versions
Update dependencies and improve tests and documentation
2 parents 9111bc9 + 60ed0af commit cc66c90

File tree

4 files changed

+44
-42
lines changed

4 files changed

+44
-42
lines changed

.travis.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,23 @@ env:
99
global:
1010
- PHPUNIT_FLAGS="-v"
1111
- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit"
12-
- SYMFONY_REQUIRE='>=2.8'
13-
- SYMFONY_DEPRECATIONS_HELPER="weak"
1412

1513
matrix:
1614
fast_finish: true
1715
include:
18-
- php: 7.1
1916
- php: 7.2
2017
- php: 7.3
18+
- php: 7.4
2119
env: deps=low
2220

2321
before_install:
2422
- phpenv config-rm xdebug.ini || true
25-
- composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
23+
- composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-main
2624

2725
install:
2826
- |
2927
if [[ $deps = low ]]; then
28+
export SYMFONY_DEPRECATIONS_HELPER=weak
3029
composer update --prefer-dist --prefer-lowest --prefer-stable
3130
else
3231
composer update --prefer-dist

README.markdown

+29-21
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ With [composer](https://getcomposer.org), require:
1818

1919
`composer require knplabs/knp-snappy-bundle`
2020

21-
Then enable it in your kernel (optional if you are using the Flex recipe with Symfony4) :
21+
Then enable it in your kernel (optional if you are using the Flex recipe with Symfony >= 4) :
2222

2323
```php
24-
// app/AppKernel.php
25-
public function registerBundles()
26-
{
27-
$bundles = array(
28-
//...
29-
new Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
30-
//...
24+
// config/bundles.php
25+
<?php
26+
27+
return [
28+
//...
29+
Knp\Bundle\SnappyBundle\KnpSnappyBundle::class => ['all' => true],
30+
//...
31+
];
3132
```
3233
Configuration
3334
-------------
@@ -74,25 +75,29 @@ The bundle registers two services:
7475
### Generate an image from a URL
7576

7677
```php
77-
$container->get('knp_snappy.image')->generate('http://www.google.fr', '/path/to/the/image.jpg');
78+
// @var Knp\Snappy\Image
79+
$knpSnappyImage->generate('http://www.google.fr', '/path/to/the/image.jpg');
7880
```
7981

8082
### Generate a pdf document from a URL
8183

8284
```php
83-
$container->get('knp_snappy.pdf')->generate('http://www.google.fr', '/path/to/the/file.pdf');
85+
// @var Knp\Snappy\Pdf
86+
$knpSnappyPdf->generate('http://www.google.fr', '/path/to/the/file.pdf');
8487
```
8588

8689
### Generate a pdf document from multiple URLs
8790

8891
```php
89-
$container->get('knp_snappy.pdf')->generate(array('http://www.google.fr', 'http://www.knplabs.com', 'http://www.google.com'), '/path/to/the/file.pdf');
92+
// @var Knp\Snappy\Pdf
93+
$knpSnappyPdf->generate(array('http://www.google.fr', 'http://www.knplabs.com', 'http://www.google.com'), '/path/to/the/file.pdf');
9094
```
9195

9296
### Generate a pdf document from a twig view
9397

9498
```php
95-
$this->get('knp_snappy.pdf')->generateFromHtml(
99+
// @var Knp\Snappy\Pdf
100+
$knpSnappyPdf->generateFromHtml(
96101
$this->renderView(
97102
'MyBundle:Foo:bar.html.twig',
98103
array(
@@ -107,17 +112,18 @@ $this->get('knp_snappy.pdf')->generateFromHtml(
107112

108113
```php
109114
use Knp\Bundle\SnappyBundle\Snappy\Response\JpegResponse;
115+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
110116
111-
class SomeController
117+
class SomeController extends AbstractController
112118
{
113-
public function imageAction()
119+
public function imageAction(Knp\Snappy\Image $knpSnappyImage)
114120
{
115121
$html = $this->renderView('MyBundle:Foo:bar.html.twig', array(
116122
'some' => $vars
117123
));
118124
119125
return new JpegResponse(
120-
$this->get('knp_snappy.image')->getOutputFromHtml($html),
126+
$knpSnappyImage->getOutputFromHtml($html),
121127
'image.jpg'
122128
);
123129
}
@@ -128,17 +134,18 @@ class SomeController
128134

129135
```php
130136
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
137+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
131138
132-
class SomeController extends Controller
139+
class SomeController extends AbstractController
133140
{
134-
public function pdfAction()
141+
public function pdfAction(Knp\Snappy\Pdf $knpSnappyPdf)
135142
{
136143
$html = $this->renderView('MyBundle:Foo:bar.html.twig', array(
137144
'some' => $vars
138145
));
139146
140147
return new PdfResponse(
141-
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
148+
$knpSnappyPdf->getOutputFromHtml($html),
142149
'file.pdf'
143150
);
144151
}
@@ -149,15 +156,16 @@ class SomeController extends Controller
149156

150157
```php
151158
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
159+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
152160
153-
class SomeController extends Controller
161+
class SomeController extends AbstractController
154162
{
155-
public function pdfAction()
163+
public function pdfAction(Knp\Snappy\Pdf $knpSnappyPdf)
156164
{
157165
$pageUrl = $this->generateUrl('homepage', array(), true); // use absolute path!
158166
159167
return new PdfResponse(
160-
$this->get('knp_snappy.pdf')->getOutput($pageUrl),
168+
$knpSnappyPdf->getOutput($pageUrl),
161169
'file.pdf'
162170
);
163171
}

composer.json

+11-16
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=7.1",
20-
"symfony/framework-bundle": "^3.4|^4.3|^5.0",
21-
"knplabs/knp-snappy": "~1.0,>=1.0.1"
19+
"php": ">=7.2.5",
20+
"symfony/framework-bundle": "^4.4|^5.1",
21+
"knplabs/knp-snappy": "^1.2"
2222
},
2323
"autoload": {
2424
"psr-4": {
@@ -30,19 +30,14 @@
3030
"Knp\\Bundle\\SnappyBundle\\Tests\\": "tests/"
3131
}
3232
},
33-
"extra": {
34-
"branch-alias": {
35-
"dev-master": "1.x-dev"
36-
}
37-
},
3833
"require-dev": {
39-
"doctrine/annotations": "~1.0",
40-
"symfony/asset": "^3.4|^4.3|^5.0",
41-
"symfony/finder": "^3.4|^4.3|^5.0",
42-
"symfony/phpunit-bridge": "^4.3|^5.0",
43-
"symfony/security-csrf": "^3.4|^4.3|^5.0",
44-
"symfony/templating": "^3.4|^4.3|^5.0",
45-
"symfony/validator": "^3.4|^4.3|^5.0",
46-
"symfony/yaml": "^3.4|^4.3|^5.0"
34+
"doctrine/annotations": "^1.11",
35+
"symfony/asset": "^4.4|^5.1",
36+
"symfony/finder": "^4.4|^5.1",
37+
"symfony/phpunit-bridge": "^4.4|^5.1",
38+
"symfony/security-csrf": "^4.4|^5.1",
39+
"symfony/templating": "^4.4|^5.1",
40+
"symfony/validator": "^4.4|^5.1",
41+
"symfony/yaml": "^4.4|^5.1"
4742
}
4843
}

tests/fixtures/config/base.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
framework:
22
secret: ThisIsNotReallyASecretSoPleaseChangeIt
3-
router: { resource: "%kernel.project_dir%/config/routing.yml" }
3+
router: { resource: "%kernel.project_dir%/config/routing.yml", utf8: true }
44
csrf_protection: true
55
validation: { enabled: true, enable_annotations: true }
66
session: ~

0 commit comments

Comments
 (0)