|
6 | 6 | [](https://styleci.io/repos/59506451)
|
7 | 7 | [](https://packagist.org/packages/codedge/laravel-fpdf)
|
8 | 8 |
|
9 |
| -This repository implements a simple [ServiceProvider](https://laravel.com/docs/master/providers) |
10 |
| -that creates a singleton instance of the Fpdf PDF library - easily accessible via a [Facade](https://laravel.com/docs/master/facades) in [Laravel](https://laravel.com/). |
11 |
| - |
12 |
| -See [FPDF homepage](http://www.fpdf.org/) for more information about the usage. |
| 9 | +Using [FPDF](http://www.fpdf.org/) made easy with Laravel. See [FPDF homepage](http://www.fpdf.org/) for more information about the usage. |
13 | 10 |
|
14 | 11 | ## Installation using [Composer](https://getcomposer.org/)
|
15 | 12 | ```sh
|
16 | 13 | $ composer require codedge/laravel-fpdf
|
17 | 14 | ```
|
18 | 15 |
|
19 |
| -## Usage |
20 |
| - |
21 |
| -### Laravel >= 5.5 |
22 |
| -Enjoy the auto discovery feature. |
23 |
| - |
24 |
| -### Laravel <5.5 |
25 |
| -To use the static interfaces (facades) you need to add the following lines to your `config/app.php`. The `[1]` is for |
26 |
| -registering the service provider, the `[2]` are for specifying the facades: |
27 |
| - |
28 |
| -```php |
29 |
| -// config/app.php |
30 |
| - |
31 |
| -return [ |
32 |
| - |
33 |
| - //... |
34 |
| - |
35 |
| - 'providers' => [ |
36 |
| - // ... |
37 |
| - |
38 |
| - /* |
39 |
| - * Application Service Providers... |
40 |
| - */ |
41 |
| - // ... |
42 |
| - Codedge\Fpdf\FpdfServiceProvider::class, // [1] |
43 |
| - ], |
44 |
| - |
45 |
| - // ... |
46 |
| - |
47 |
| - 'aliases' => [ |
48 |
| - // ... |
49 |
| - 'Fpdf' => Codedge\Fpdf\Facades\Fpdf::class, // [2] |
50 |
| -] |
51 |
| -``` |
52 |
| - |
53 |
| -Now you can use the facades in your application. |
| 16 | +## Configuration |
54 | 17 |
|
55 |
| -## Configuration (optional) |
56 | 18 | Run
|
57 | 19 | `php artisan vendor:publish --provider="Codedge\Fpdf\FpdfServiceProvider" --tag=config`
|
58 | 20 | to publish the configuration file to `config/fpdf.php`.
|
59 |
| - |
60 |
| -Open this file and enter the correct page settings, if you do not want the defaults. |
61 | 21 |
|
62 |
| -## Basic example |
63 | 22 |
|
64 |
| -If you want to use the facade you can see a basic example here: |
65 |
| - |
66 |
| -```php |
67 |
| -// app/Http/routes.php | app/routes/web.php |
68 |
| - |
69 |
| -Route::get('/', function () { |
70 |
| - |
71 |
| - Fpdf::AddPage(); |
72 |
| - Fpdf::SetFont('Courier', 'B', 18); |
73 |
| - Fpdf::Cell(50, 25, 'Hello World!'); |
74 |
| - Fpdf::Output(); |
75 |
| - |
76 |
| -}); |
77 |
| -``` |
78 |
| - |
79 |
| -Of course you can also inject the singleton instance via dependency injection. See an example here: |
| 23 | +## Usage |
80 | 24 |
|
81 | 25 | ```php
|
82 | 26 | // app/Http/routes.php | app/routes/web.php
|
|
0 commit comments