You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Below one can find instructions on how to set this up on Laravel Vapor.
Step 1
Since we need to install custom packages, one cannot use the existing runtimes that Vapor offers. We will need to create a docker runtime. I am doing this for the staging environment as an example.
Change the staging environment in vapor.yml file as follows:
runtime: 'php-8.0:al2'
to
runtime: docker
Step 2
Create a staging.Dockerfile with the following content. Note that you need pango-dev instead of pango. Even though alpine linux repos list pango as an available download, couldn't get this to work. Also, the instructions are for installing weasyprint without using python environments. Here are the contents of the dockerfile.
FROM laravelphp/vapor:php80
RUN apk update
RUN apk add py3-pip py3-pillow py3-cffi py3-brotli gcc musl-dev python3-dev pango-dev font-noto
RUN pip install weasyprint
COPY . /var/task
Step 3
Now how you will use weasyprint package in your project is up to you. Below is a simple example to show it works. Add a route to web.php
Now you can deploy to vapor with vapor deploy staging.
Thoughts
First off kudos to @mikerockett for creating the package. Great work! Getting a html to pdf package working on vapor isn't easy. I tried many of the popular ones, but the ones that work easily like dompdf don't have the latest css support. Others which use a rendering engine like wkhtmltopdf have very old rendering engines.
The best could have been puppeteer on chromium, but that just doesn't run on Vapor. Still trying to get it running. But really loved the ease of WeasyPrint and this wrapper which just works! And sometimes that is all that matters.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary
Below one can find instructions on how to set this up on Laravel Vapor.
Step 1
Since we need to install custom packages, one cannot use the existing runtimes that Vapor offers. We will need to create a docker runtime. I am doing this for the staging environment as an example.
Change the staging environment in vapor.yml file as follows:
to
Step 2
Create a
staging.Dockerfile
with the following content. Note that you needpango-dev
instead ofpango
. Even though alpine linux repos list pango as an available download, couldn't get this to work. Also, the instructions are for installing weasyprint without using python environments. Here are the contents of the dockerfile.Step 3
Now how you will use weasyprint package in your project is up to you. Below is a simple example to show it works. Add a route to
web.php
Final Step
Now you can deploy to vapor with
vapor deploy staging
.Thoughts
First off kudos to @mikerockett for creating the package. Great work! Getting a html to pdf package working on vapor isn't easy. I tried many of the popular ones, but the ones that work easily like dompdf don't have the latest css support. Others which use a rendering engine like wkhtmltopdf have very old rendering engines.
The best could have been puppeteer on chromium, but that just doesn't run on Vapor. Still trying to get it running. But really loved the ease of WeasyPrint and this wrapper which just works! And sometimes that is all that matters.
Cheers!
Beta Was this translation helpful? Give feedback.
All reactions