laravel-pdf icon indicating copy to clipboard operation
laravel-pdf copied to clipboard

Made it Compatible with Lumen

Open kiasaty opened this issue 5 years ago • 9 comments

Hi,

I just made a few changes to make your great package compatible with Lumen. Lumen is a Laravel micro-framework for making Restful APIs.

  • Changed Config facade to config helper.
  • Changed View facade to view helper.
  • changed config_path() to app()->basePath('config/')

kiasaty avatar Oct 22 '19 17:10 kiasaty

@kiasaty Looks good. Never worked with Lumen yet. So all we have to do is ensure to not use any facades inside the plugin?

niklasravnsborg avatar Oct 23 '19 15:10 niklasravnsborg

@niklasravnsborg some facades and helpers are not present in Lumen. Lumen is built to be lighter and faster. So some functionalities are cut out.

Facades are disabled by default in Lumen. You can enable them by uncommenting one line of code, but still only some of them are present. So it's better to not use facades for speed concerns.

For example, in the project I'm working on at the moment, facades are completely disabled. So I had to call app('pdf-wrapper')->loadView() instead of Pdf::loadView() to use your package in the app.

If you are merging this, also change File::get() to file()

PS: thank you for developing this package. Our language is rtl and your package is a rescue. :)

kiasaty avatar Oct 23 '19 21:10 kiasaty

@kiasaty This would be a good idea to make the package compatible with Lumen. Please make your last changes and let me know when it's done. Then, I will test it on Lumen with Farsi and other complicated languages (with OTL) to make sure that it works just like now it does on Laravel.

erfansahaf avatar Oct 26 '19 08:10 erfansahaf

@erfansahaf Very nice. You can try the composer test command also :)

niklasravnsborg avatar Oct 26 '19 18:10 niklasravnsborg

@kiasaty Is 9733bc0 your last changes? Should I go for a test?

erfansahaf avatar Oct 30 '19 08:10 erfansahaf

@erfansahaf yeah it is the last changes. you can go for a test now.

kiasaty avatar Oct 30 '19 09:10 kiasaty

Hi guys, @niklasravnsborg @erfansahaf Did you test it?

kiasaty avatar Dec 02 '19 08:12 kiasaty

Hey Ehsan,

Sorry for the late reply, I'm a bit busy right now, but once I have reviewed your PR, I'll let you and Niklas know.

On Mon, 2 Dec 2019 at 12:14, Ehsan Kiasaty [email protected] wrote:

Hi guys, @niklasravnsborg https://github.com/niklasravnsborg @erfansahaf https://github.com/erfansahaf Did you test it?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/niklasravnsborg/laravel-pdf/pull/148?email_source=notifications&email_token=AC3UVCBZUUQ3NZSCDZICAO3QWTDH7A5CNFSM4JDTDKXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFSWMHI#issuecomment-560293405, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3UVCGVIBYW3GRJBBB74RLQWTDH7ANCNFSM4JDTDKXA .

erfansahaf avatar Dec 03 '19 11:12 erfansahaf

@kiasaty Hey! I tried to pull your changes today and run the test suite with composer test. The simple test case passed. The second test failed with the following error.

1) niklasravnsborg\LaravelPdf\Test\PdfTest::testExposifyPdfExposeIsCorrect
Mpdf\MpdfException: WriteHTML() requires $html be an integer, float, string, boolean or an object with the __toString() magic method.

/Users/niklasravnsborg/Code/laravel-pdf/vendor/mpdf/mpdf/src/Mpdf.php:12975
/Users/niklasravnsborg/Code/laravel-pdf/src/LaravelPdf/Pdf.php:56
/Users/niklasravnsborg/Code/laravel-pdf/src/LaravelPdf/PdfWrapper.php:28
/Users/niklasravnsborg/Code/laravel-pdf/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:239
/Users/niklasravnsborg/Code/laravel-pdf/tests/PdfTest.php:18

I don't have time to look into it currently but maybe you have an idea how to fix it?

Niklas

niklasravnsborg avatar Feb 01 '20 18:02 niklasravnsborg