У меня локальный Apache2.4 в окне 10 с версией php 7.2.4. Когда я отправляю свою форму html на сервер, я получаю Uncaught Error: класс 'Knp \ Snappy \ Pdf' не найден в C: \ Apache24 \ htdocs \ bitul-rishum \ pdf. php: 15 PDF . php is:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if (!isset($_POST['html']) || empty($_POST['html'])) {
echo 'No no no!!! ))))';
return;
}
$dir = __DIR__;
require_once $dir . '/../httpdocs/vendor/autoload.php';
// $path = '/var/www/vhosts/5.automas.co.il/4.automas.co.il/public/upload/';
$path = '/public/upload/';
use Knp\Snappy\Pdf;
$snappy = new Pdf('C://"Program Files"/wkhtmltopdf/bin/wkhtmltopdf.exe');
ob_start();
?>
<html dir="rtl" lang="he-IL">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>בקשת העברה למסגרת אחרת - בתי ספר - מחלקת החינוך</title>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" ></script>
</head>
<body>
<div class="container">
<main><!-- main[white-bg] -->
<?php echo str_replace("https://tk.bitul-rishum.automas.co.il", $dir, $_POST['html']);?>
</main>
</div>
<script type="text/javascript">
$('select').each(function(){
$(this).replaceWith('<span style=" border-bottom: 1px solid #000; display: inline-block; height: 27px; margin-bottom: 5px;" class="text">'+$(this).val()+'</span>');
});
</script>
$snappy->setOption('page-size', 'A4');
$snappy->setOption('zoom', '1');
$snappy->setOption('margin-top', '0');
$snappy->setOption('margin-right', '0');
$snappy->setOption('margin-bottom', '0');
$snappy->setOption('margin-left', '0');
$pdfname = uniqid().'_'.time().'.pdf';
$snappy->generateFromHtml($html, $path .$pdfname);
if (file_exists($path.$pdfname)) {
echo $pdfname;
} else {
echo "error";
}
die();
Я получаю «Uncaught Error: класс 'Knp \ Snappy \ Pdf' не найден в C: \ Apache24 \ htdocs \ bitul-rishum \ pdf. php: 15 "сообщение в http-ответе на запрос на публикацию, отправленный из main. js.
Я пытаюсь переустановить snappy с помощью" composer require knplabs / knp-snappy ", и это не удалось, сказав : ..... можно установить только из: .... и последний:
Can only install one of: symfony/process[v5.0.4, v4.2.4].
Installation request for symfony/process (locked at v4.2.4) -> satisfiable by symfony/process[v4.2.4].
Installation failed, reverting ./composer.json to its original content.
когда я набираю: PS C:\Apache24\htdocs\httpdocs\vendor> composer global why symfony/process -t
Я получаю:
Changed current directory to C:/Users/user/AppData/Roaming/Composer
symfony/process v4.4.3 Symfony Process Component
└──laravel/installer v1.5.0 (requires symfony/process ~3.0|~4.0)
└──__root__ (requires laravel/installer ~1.1)
composer. json:
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"barryvdh/laravel-dompdf": "^0.8.4",
"barryvdh/laravel-snappy": "^0.4.4",
"consoletvs/charts": "6.*",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0",
"maatwebsite/excel": "^3.1",
"nesbot/carbon": "^2.24"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}
Пожалуйста, помогите, Менахем