Install Invoice Ninja v5 using Caddy

I am hosting InvoiceNinja v5 using Caddy, but a few features don’t seem to work quite right, including PDF generation, file uploads, and the mobile app.

Does anyone know the proper rewrite syntax for running InvoiceNinja on Caddy?

Current Config

https://invoice.domain.com {
	root * /var/www/html/invoice.domain.com/public
	php_fastcgi unix//run/php/php7.4-fpm.sock
	encode zstd gzip
	file_server
	try_files {path} /public/{path}
        log {
          output file /tmp/caddy.log
          format console
        }

}

Hi,

These could be separate problems:

  • Does using PhantomJS work?
  • Are there any error in storage/logs/
  • What are you seeing in the mobile app?

My PDF issue is the same as described here: Test PDF button working, invoice PDF not working

The mobile app returns a 500 error when trying to login

I’ll check the logs when I get home from work.

@mtdev

We’ve changed the default PDF engine. If you can update to the latest and also run

composer install --no-dev

you’ll also want to make sure the .env var

PHANTOMJS_PDF_GENERATION
is set to false

The app works now, I just needed to use the new app (duh!)

The logs seem uneventful

[2020-12-29 03:27:13] production.INFO: https://invoice.domain.com/tmp_pdf/l3NfxvldCbTsHwGXWbYos62Hgpoi0PyK  
[2020-12-29 03:27:19] production.INFO: https://invoice.domain.com/tmp_pdf/aF42IPbVHoJezUbjQKpKlFUP25pX4YCD  
[2020-12-29 03:27:27] production.INFO: https://invoice.domain.com/tmp_pdf/iwStSPYicsuAleoYHUeVt5fYGGCt5sNR  
[2020-12-29 03:27:40] production.INFO: https://invoice.domain.com/tmp_pdf/9KhjKhlE5urWqb8dAIIdpqzz8EAcYL2V  
[2020-12-29 03:27:50] production.INFO: https://invoice.domain.com/tmp_pdf/EWIC5xV4LFNLXgmYWMTz9sUPOhOsbbBn  

But, after I updated to v5.0.41-C35, installed the Chromium dependencies, set PHANTOMJS_PDF_GENERATION to false and ran composer install --no-dev, I had some potentially relevant error output.

$ composer install --no-dev
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Package asgrim/ofxparser is abandoned, you should avoid using it. No replacement was suggested.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: fedeisas/laravel-mail-css-inliner
Discovered Package: fideloper/proxy
Discovered Package: intervention/image
Discovered Package: laravel/slack-notification-channel
Discovered Package: laravel/socialite
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: livewire/livewire
Discovered Package: nesbot/carbon
Discovered Package: nwidart/laravel-modules
Discovered Package: sentry/sentry-laravel
Discovered Package: turbo124/beacon
Discovered Package: turbo124/laravel-gmail
Discovered Package: webpatser/laravel-countries
Package manifest generated successfully.
69 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> vendor/bin/snappdf download
Starting download. Revision: 839671
Download completed. Extracting the zip archive.
PHP Warning:  mkdir(): File exists in /var/www/html/invoice.domain.com/vendor/beganovich/snappdf/src/Command/DownloadChromiumCommand.php on line 80
PHP Warning:  ZipArchive::extractTo(): Invalid or uninitialized Zip object in /var/www/html/invoice.domain.com/vendor/beganovich/snappdf/src/Command/DownloadChromiumCommand.php on line 82
PHP Warning:  ZipArchive::close(): Invalid or uninitialized Zip object in /var/www/html/invoice.domain.com/vendor/beganovich/snappdf/src/Command/DownloadChromiumCommand.php on line 83
Archive extracted. Creating symlink for 839671-Linux_x64
Completed! 839671-Linux_x64 currently in use.

Aside from all that, still having PDF generation issues.

Looks like you’re trying to download the same version of Chromium again. Nothing to worry about, I’ll push an update into snappdf, so you don’t see that message next time.

When you try to generate PDF, is there any log in storage/logs/laravel.log?

Make sure you have installed required Chromium libraries also:

I’m not sure what fixed it, but after I created a new invoice I can see the PDF.

Trying to View PDF on an previously created recurring invoice results in the same error. Are there some files cached that I can clear away?

There shouldn’t be!
Here’s what you can do if it’s not deal-breaking.

Navigate to public/storage:

There you should see some random strings. You can browse that folder & find PDFs of invoices. You can freely delete them and try to view the invoice in the admin panel again. They should be regenerated.