I am using laravel 8 and have installed dompdf on MAMP and everything works fine, but as soon i deployed it to my production server dompdf does not work anymore.
I get the following message: Failed to load PDF document.
When I check the server logs i only a see 500 error without any additional details.
Is there anyone who has had the same issue?
I am using Laravel 8.12 with php 7.3.27 with dompdf
"barryvdh/laravel-dompdf": "^0.9.0",
This is the code I use:
$pdf = PDF::loadView('pdf.letters', ['batch' => $batch]);
return $pdf->stream('document.pdf');
I have checked and made sure:
MBString extension is enabled
DOM extension
I don't load in any custom fonts.
What I have tried:
Downgrading from dompdf 0.9.0 to 0.8.0
List item
Apache log returns no additional information only a 500 error.
Laravel log returns the following:
stdout: ""
command: /usr/local/bin/wkhtmltopdf --lowquality '/tmp/knp_snappy6039f3cdd6edf5.34383100.html' '/tmp/knp_snappy6039f3cdd702b5.29005326.pdf'. at /var/www/vhosts/domain.com/httpdocs/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php:381)
This my composer.json :
"require": {
"php": "^7.3|^8.0",
"barryvdh/laravel-dompdf": "^0.8.3",
"barryvdh/laravel-snappy": "^0.4.8",
"carlos-meneses/laravel-mpdf": "^2.1",
"darryldecode/cart": "^4.2",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"gladcodes/keygen": "^1.1",
"guzzlehttp/guzzle": "^7.0.1",
"h4cc/wkhtmltopdf-i386": "0.12.x",
"intervention/image": "^2.5",
"knplabs/knp-snappy": "^1.2",
"laravel/framework": "^8.12",
"laravel/tinker": "^2.5",
"laravelcollective/html": "^6.2",
"mollie/laravel-mollie": "^2.0",
"picqer/php-barcode-generator": "^2.1",
"spatie/laravel-medialibrary": "^7.0.0",
"stripe/stripe-php": "^7.74"
},
Thank you.
Related
I have this error while using the MediaLibrary package
Interface 'Spatie\MediaLibrary\HasMedia' not found
Trait 'Spatie\MediaLibrary\InteractsWithMedia' not found
My project details :-
php : 7.3.22
laravel : 7.28.3
I have tried follow the documentation v7 and also run the command below
composer require spatie/laravel-medialibrary
Other than that, I have also checked on other post which I have follow most of the steps but still getting back the same error
composer.json
"require": {
"php": "^7.2.5",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "^7.0",
"laravel/tinker": "^2.0",
"laravelcollective/html": "^6.2",
"spatie/laravel-activitylog": "^3.16",
"spatie/laravel-medialibrary": "^7.19"
},
Model
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
class Applicant extends Model implements HasMedia
{
use LogsActivity, InteractsWithMedia;
}
Make sure to follow the documentation for the specific version of Laravel-medialibrary that you are using. In your case version 7. It looks like you were following the version 8 documentation.
In version 7, the trait is Spatie\MediaLibrary\HasMedia\HasMediaTrait instead of Spatie\MediaLibrary\InteractsWithMedia. And the interface is Spatie\MediaLibrary\HasMedia\HasMedia instead of Spatie\MediaLibrary\HasMedia.
If you want to use version 8 instead, change your requirements to "spatie/laravel-medialibrary": "^8.0" and then run composer update.
why does View::make() not exist in laravel docs?
I have gone through on xVersion/views pages of all versions of Laravel docs, but I couldn't find any statement about View::make(). who can explain to me how it works?
additional info, I'm learning Aimeos Laravel package.
I don't think View::make is from Aimeos packages.
because, I see
composer.json
> "require": {
> "php": "^7.2.5",
> "aimeos/aimeos-laravel": "dev-master",
> "fideloper/proxy": "^4.2",
> "fruitcake/laravel-cors": "^2.0",
> "guzzlehttp/guzzle": "^6.3",
> "laravel/framework": "^7.24",
> "laravel/tinker": "^2.0",
> "laravel/ui": "^2.4"
> },
Many things in Laravel have multiple ways of referencing them.
The documentation prefers the use of the cleaner, less verbose view() helper, but you can use View::make if you prefer.
The API docs for View::make are at https://laravel.com/api/8.x/Illuminate/Contracts/View/Factory.html#method_make.
View::make is calling a make method on the View facade. This was how views were referenced in Laravel 4.x, but Laravel 5.x introduced the global view helper that does the same thing, just with a few less keystrokes.
Therefore, View::make('shop::page.privacy') is the same as view('shop::page.privacy').
Any ideas on what is going wrong here? I'm totally stumped.
Code
I'm running the following code on a local development server (MacOS with Laravel Valet):
$file = $request->file('uploaded_file');
$folder = '001-testing';
$filename = '12345.'.$file->extension();
$s3_path = $file->storeAs($folder, $filename, 's3');
Result
504 Gateway Time-out
Not a very useful error!
.env
AWS_ACCESS_KEY_ID=*****
AWS_SECRET_ACCESS_KEY=*****
AWS_DEFAULT_REGION=us-west-2
AWS_BUCKET=*****
AWS_ENDPOINT=https://s3.us-west-2.amazonaws.com
AWS_URL=https://s3.us-west-2.amazonaws.com
I'm not sure about ENDPOINT and URL - do I have these right? These are new variables from previous Laravel versions.
composer.json
"require": {
"php": "^7.2.5",
"aws/aws-sdk-php": "^3.147",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "^7.0",
"laravel/tinker": "^2.0",
"league/flysystem-aws-s3-v3": "^1.0",
"league/flysystem-cached-adapter": "^1.1"
By default you cannot access S3 buckets with the http protocol, if http is a requirement configure your bucket as a website endpoint and allow public access.
How to S3 bucket for static webhosting
If http/https isn't a requirement, switch your AWS_ENDPOINT & AWS_URL variables over to s3:// protocol and direct them to your specific bucket
I am playing around with Lumen, I installed it via Lumen installer. After I do composer install, I try to use artisan but it throws the following error:
ReflectionException: Class redis does not exist in Container.php on line 752
My composer.json:
"require": {
"php": ">=7",
"ext-pdo_pgsql": "*",
"ext-soap": "*",
"guzzlehttp/guzzle": "^6.3",
"laravel/lumen-framework": "5.5.*",
"laravel/tinker": "^1.0",
"vlucas/phpdotenv": "~2.2"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.4",
"doctrine/dbal": "^2.5"
},
Thanks in advance.
I had the same.
Solution:
composer require illuminate/redis
Register it in bootstrap/app.php by calling
$app->register(Illuminate\Redis\RedisServiceProvider::class);
in the file, under Register Service Providers.
From this aricle.
From Lumen's official documentation at https://lumen.laravel.com/docs/7.x/cache :
Redis Support:
Before using a Redis cache with Lumen, you will need to install the illuminate/redis package via Composer. Then, you should register the Illuminate\Redis\RedisServiceProvider in your bootstrap/app.php file:
$app->register(Illuminate\Redis\RedisServiceProvider::class);
If you have not called $app->withEloquent() in your bootstrap/app.php file, then you should call $app->configure('database'); in the bootstrap/app.php file to ensure the Redis database configuration is properly loaded.
Hi on my localhost i can upload images perfect with Image Intervention. On my server i can't the say: Fileinfo extension must be installed/enabled to use Intervention Image. I change my PHP Version to 5.3.29 before are in 5.6. I enable File Info but still not working. After upload i delete vendor and i run
composer install
and
composer dump-autoload
and later i upload it to my server but the problem continues.
Here my composer.json file:
"require": {
"php": ">=5.3",
"laravel/framework": "5.2.*",
"laravelcollective/html":"*",
"laracasts/flash": "^2.0",
"cviebrock/eloquent-sluggable": "^4.0",
"intervention/image": "^2.3",
"laravel/socialite": "^2.0",
"cviebrock/image-validator": "^2.1"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
Some one can help me here? Thanks :)