0

I am running a php laravel program with laravel v 10 and php 8.1.2 which is supposed to create a pdf document. I have no problem when running the program in localhost but I am getting this issue after the system is hosted in shared hosting with a cPanel.

protected function passedValidation()
{
       Pdf::loadView('quotation.quotationpdf', [

            'taxes' => $this->taxes,

            'force_majuere' => $this->force_majuere,

        ])->save(storage_path('app/public/quotations/quotation.pdf'));
}

This is my code and error is being shown in 'force_majuere' => $this->force_majuere, this line.

I have searched the internet and my problem is close to this question but there is no answers or solution provided. Some other solutions I have found are to upgrade php to 8.2 but it is not possible as php 8.2 is not supported by my server. I have tested my program in php 8.1.2 and php 8.2 in local environment but my remote server is using php 8.1.21 could this be the issue, or issue lies in laravel-dompdf which I am using version 2.0.1.

  • Does this answer your question? [Why I am suddenly getting a "Typed property must not be accessed before initialization" error when introducing properties type hints?](https://stackoverflow.com/questions/59265625/why-i-am-suddenly-getting-a-typed-property-must-not-be-accessed-before-initiali) – Tobias Aug 21 '23 at 11:23
  • @Tobias I am aware with this thread and it addresses the change made in php 7.4 but it doesn't solve my problem. I believe my problem has something to do with php 8.1 version of cPanel or dompdf 2.0.1. – Arjan Shrestha Aug 21 '23 at 11:33
  • Can you show the definition for `$this->force_majuere`? And do you modify it at all in the `__construct()` method? – aynber Aug 21 '23 at 11:34
  • @aynber error has nothing to do with `$this->force_majuere`, as I have few other pages which makes pdf and they too throws same error on the last line of the array of second argument of `Pdf::loadView()` function – Arjan Shrestha Aug 21 '23 at 11:47
  • Can you provide the full error & trace? – aynber Aug 21 '23 at 11:50
  • @aynber https://flareapp.io/share/17xDV8L7 – Arjan Shrestha Aug 21 '23 at 12:00
  • Darn, that doesn't help much. If you remove that line, does it work, or does the error move to the previous line? – aynber Aug 21 '23 at 12:41
  • @aynber if I remove that line of code it moves to previous line. – Arjan Shrestha Aug 22 '23 at 04:41

0 Answers0