Using Ninja on PHP 7.4

I have been using Ninja v.4.5.13 whitelabeled. I have no desire to upgrade to the Beta version. I’m not great with managing the web server, so I don’t want to need to fix issues with beta software… but we upgraded our webserver to PHP 7.4 and are disappointed to see that Ninja stopped working. Is there a way to get it to work? I would MUCH prefer to just use the current version and not go to the beta.

But in case, I thought I would try to beta.

I am using an AWS EC2 Server running their Amazon Linux AMI2 distro.

I tried installing 5.0.17, the installation instructions are too complicated for me. I’ve spent several hours tonight trying to get it to work, and can’t. I get to the setup screen, but when I click “Test PDF” all I get is “Oops, looks like something isn’t correct!” When I check the logs, I see there is an error saying:

production.INFO: The command “PATH=$PATH:/usr/local/bin NODE_PATH=npm root -g node ‘/data/www/live/ninja5/vendor/spatie/browsershot/src/…/bin/browser.js’ '{“url”:“”,“action”:“pdf”,“options”:{“path”:”/data/www/live/ninja5/public/test.pdf",“args”:["–no-sandbox"],“viewport”:{“width”:800,“height”:600}}}’" failed.

I have tried to install npm, but I do get errors saying there are required programs not available (filbers and node-sass). Fibers nor Node-SASS are available through yum, so I’m not sure how to do that. NodeJS is installed.

When I go to the old version of Ninja there is no option for migration under the Account Management settings, as the instructions say there should be. I’m unclear from the instructions if I should set up a new database for Ninja5 or if I should connect it to the same database. Does migration copy it from the old database into a new one or should I use the same?

Thanks for any help you can provide.

Sorry, PHP 7.4 isn’t supported by the v4 app

Sorry… saw you had other questions.

For v5 node/npm are optional, you can use instead.

Are you the owner of the account? Only the owner will see the migration option.

Yes, I am the owner of the account. I am using an older version though (4.5.13) could that be the reason?

Do you know what the error message I posted means and how I can work around that to get v5 installed? Do I need to install / enable Phantomjs to try that? I don’t see any installation instructions on the link you sent, so I’m not sure how that works.

Do I use the current database to set up the v5 or do I create a new database?

Thank you.

You need to update to the latest version to use the migration tool.

Which error specifically are you referring to?

When you install v5 you need to create a blank new database.

The error in the laravel.log file after I run the Test PDF button on the new v5 install is:

production.INFO: The command “PATH=$PATH:/usr/local/bin NODE_PATH= npm root -g node ‘/data/www/live/ninja5/vendor/spatie/browsershot/src/…/bin/browser.js’ '{“url”:“”,“action”:“pdf”,“options”:{“path”:”/data/www/live/ninja5/public/test.pdf",“args”:["–no-sandbox"],“viewport”:{“width”:800,“height”:600}}}’" failed.

Try setting this in the .env file


I’m sorry, I don’t know what that means. What .env file?

Also, I upgraded the old Ninja and see migration.
On v5 I to just ignore the error to continue, but then also got an error when I try to test the webserver. The log says:

[2020-09-27 14:02:31] production.INFO: array (
‘message’ => ‘count(): Parameter must be an array or an object that implements Countable’,
‘action’ => ‘SetupController::checkMail()’,

There is a .env file in the root folder of the project

Are you using the latest v5 release?

I am using version 5.0.17.

Updating the .env did seem to work.

Given that I’m using that, do I need to get a new key for PhantomJS?

I was able to install Ninja v5 and login. I started the migration process on the old version, and ran into a few issues, (folder permissions, etc.). but resolved those. The migration says it has run. But now I can not log into the new v5 Installation after running the migration. I receive a red “XMLHttpRequest error” on the login screen. On another browser it shows a “500: Server Error” message on the login screen.

In the laravel.log the last message was:

production.INFO: POST - 52 queries - 0.4978928565979

The second to last error message was:

production.ERROR: Argument 1 passed to App\Transformers\CompanyUserTransformer::transform() must be an instance of App\Models\CompanyUser, null given, called in /data/www/live/ninja5/vendor/league/fractal/src/Scope.php on line 407 {"userId":1,"exception":"[object] (TypeError(code: 0): Argument 1 passed to App\\Transformers\\CompanyUserTransformer::transform() must be an instance of App\\Models\\CompanyUser, null given, called in /data/www/live/ninja5/vendor/league/fractal/src/Scope.php on line 407 at /data/www/live/ninja5/app/Transformers/CompanyUserTransformer.php:46)

Thanks for your help.

Just FYI after I changed the .env file and then ran the “Test PDF” button it says success and then opens a new window which leads to a “500 | Server Error” message. The page it tried opening was:

… in the /ninja5/storage/app folder I do see a test.pdf file that was created at the same time that I tried running the test, so it looks like it did create a PDF, but the domain is pointed at the /ninja5/public/ folder, so I’m guessing that is why I’m getting the 500 error. I checked the PDF and it is valid.

Also, I was able to fix the mail issue – that was my fault, I had the AWS email server set incorrectly, so that has been resolved.

hi @cfullerbhope-org

  1. In regards to the PDF links not working please try the following
php artisan storage:link
php artisan optimize
  1. When you attempted the migration, did you have the most up to date versions of both the V4 and V5 apps?
  1. I ran the artisan tool(s).

  2. Yes. They are on separate machines / IP addresses. The old server is on version 4.5.19 and the new server has 5.0.17

  3. Now when I try to log into the new server (5.0.17) I am getting a new error: “Error: please check that Invoice Ninja v5 is installed on the server” on the log in screen when trying to log in. I don’t see anything new in the laravel.log


The third error indicates that the URL may be wrong.

You can test the URL by entering it into a browser looking something like this

Using that, I am getting:

{“message”:“Invalid token”,“errors”:{}}

Ok, so it looks like the underlyling error isn’t being exposed because APP_DEBUG is set to FALSE in your .env file

To understand why it is failing, you’ll need to set APP_DEBUG=TRUE in the .env file and then run php artisan optimize once that is done try logging in again, you’ll see the error in your logs.

Please note, you don’t want to run your app in DEBUG=TRUE for too long. so make sure you flick this back to FALSE afterwards.

I tried changing the APP_DEBUG=TRUE and ran artisan optimize and am getting the same results.

The only entry into the log file is:

production.INFO: GET - 0 queries - 0.014193058013916

It looks like it is a DB connection error, your user/password combination is throwing a MySQL error.

Is there somewhere other than the .env file that would store the mySQL credentials, because what it is in the .env file is correct.

I decided to scrap it and start over. And unfortunately, I’m getting the same result. Here is a step by step explanation of what I did to start over:

  • Deleted v5 database and recreated a blank database

  • Removed the ninja 5 folder and recreated it from the download

  • Changed the .env file to include: PHANTOMJS_KEY=‘a-demo-key-with-low-quota-per-ip-address’

  • Ran: sudo php artisan storage:link

  • Ran: sudo php artisan optimize

  • Opened the website

  • Completed the setup screens all of the tests were successful. I’m using the same username/password combo that I use for the old version.

  • Signed into the new V5.0.17 version. No company set up just blank data, but log in worked.

  • Opened the old v4.5.19 and went to Settings:Account Management:Start Migration

  • Used “Self-hosted” option. Entered the domain for the new v5 install, used the same username/password for both, selected the only company by ID. (Not selecting “Force migration”)

  • The old server works for quite a while (~5 mins) and then returns a message: “Migration has started. We’ll update you with status, on your company e-mail.”. (This was more than an hour ago, and I still haven’t received any emails).

  • Now when I try to log into the new V5 server I receive a “500:Server Error”

  • Last two errors in storage/logs/laravel.log are:

    • production.ERROR: Argument 1 passed to App\Transformers\CompanyUserTransformer::transform() must be an instance of App\Models\CompanyUser, null given, called in /data/www/live/ninja5/vendor/league/fractal/src/Scope.php on line 407 {“userId”:1,“exception”:"[object] (TypeError(code: 0): Argument 1 passed to App\Transformers\CompanyUserTransformer::transform() must be an instance of App\Models\CompanyUser, null given, called in /data/www/live/ninja5/vendor/league/fractal/src/Scope.php on line 407 at /data/www/live/ninja5/app/Transformers/CompanyUserTransformer.php:46)
    • production.INFO: POST - https://***.org/api/v1/login: 52 queries - 0.49500489234924
  • I changed the .env file to turn on debuging: APP_DEBUG=true

  • Tried logging in again from browser. Still get the “500: Server Error” message on the login screen. Same error messages in storage/logs/laravel.log

  • Tried to go to and the response I receive is: {“message”:“Invalid token”,“errors”:{}}

  • A new entry was put into the storage/logs/laravel.log:

    • production.INFO: GET - https://***.org/api/v1/ping: 0 queries - 0.012839078903198
  • I checked the .env file, and the database username and password are correct to connect to the new database that was setup for V5.

@cfullerbhope-org thanks for this detailed response.

When the migration commences there is a bunch of logs written inside the V5 installation ie importing clients, importing quotes… it should finish with a message like

Completed🚀🚀🚀🚀🚀 at 

It sounds like the migration isn’t completing leaving the system in an unusable state.