Sé que ya han hecho esta pregunta antes, pero las respuestas no me sirven porque me parece que tengo todo bien.
Estoy tratando de usar phpspreadsheet por primera vez, por motivos de aprendizaje, y tambien estoy usando composer por primera vez. Trabajo en mi servidor local usando Xampp.
Instalé composer, me moví a mi directorio y ejecuté "composer require phpoffice/phpspreadsheet". Aparentemente todo bien, me generó un subdirectorio vendor, un archivo composer.json y otro composer.lock
Pensaba que lo tenía todo perfecto, pero cuando trato de ejecutar me da el error
PHP Fatal error: Uncaught Error: Class 'phpoffice\phpspreadsheet\Spreadsheet' not found in ....
El código es el siguiente:
use phpoffice\phpspreadsheet\Spreadsheet;
use phpoffice\phpspreadsheet\Writer\Xlsx;
include('Db.php');
include('quoteadmin_function.php');
require 'vendor/autoload.php';
if ( 0 < $_FILES['file']['error'] ) {
$result = 'Error: ' . $_FILES['file']['error'] . '<br>';
}
else {
$archivo = 'uploads/' . $_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], $archivo);
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
error_log("Importando " . $highestRow . " " . $highestColumn);
Y el archivo error es el siguiente:
[Mon Feb 01 11:38:51.945605 2021] [ssl:warn] [pid 5684:tid 252] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Feb 01 11:38:52.289609 2021] [ssl:warn] [pid 5684:tid 252] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Feb 01 11:38:52.423611 2021] [mpm_winnt:notice] [pid 5684:tid 252] AH00354: Child: Starting 150 worker threads.
[Mon Feb 01 11:42:32.937500 2021] [php7:notice] [pid 5684:tid 1520] [client ::1:53569] SELECT * FROM tblquote LEFT OUTER JOIN tblcn ON tblquote.Cn = tblcn.CnId LEFT OUTER JOIN tblcompany ON tblquote.Company = tblcompany.CompId LEFT OUTER JOIN tblcuts ON tblquote.Cut = tblcuts.Cutid LEFT OUTER JOIN tblcattle ON tblquote.Cattle = tblcattle.CatId LEFT OUTER JOIN tblbreed ON tblquote.Breed = tblbreed.BreId WHERE (tblcn.valEn LIKE "%%" OR User LIKE "%%" OR tblcompany.valEn LIKE "%%" OR Plant LIKE "%%" OR tblcuts.valEn LIKE "%%" OR tblcattle.valEn LIKE "%%" OR tblbreed.ValEn LIKE "%%" ) ORDER BY qDate , referer: http://localhost:8081/quotes.agro_equity/AdminDataQuoteAdmin.php
[Mon Feb 01 11:42:43.560639 2021] [php7:error] [pid 5684:tid 1520] [client ::1:53575] PHP Fatal error: Uncaught Error: Class 'phpoffice\\phpspreadsheet\\Spreadsheet' not found in C:\\xampp\\htdocs\\quotes.agro_equity\\quoteadmin_import.php:19\nStack trace:\n#0 {main}\n thrown in C:\\xampp\\htdocs\\quotes.agro_equity\\quoteadmin_import.php on line 19, referer: http://localhost:8081/quotes.agro_equity/AdminDataQuoteAdmin.php
[Mon Feb 01 11:42:47.722693 2021] [php7:notice] [pid 5684:tid 1520] [client ::1:53587] SELECT * FROM tblquote LEFT OUTER JOIN tblcn ON tblquote.Cn = tblcn.CnId LEFT OUTER JOIN tblcompany ON tblquote.Company = tblcompany.CompId LEFT OUTER JOIN tblcuts ON tblquote.Cut = tblcuts.Cutid LEFT OUTER JOIN tblcattle ON tblquote.Cattle = tblcattle.CatId LEFT OUTER JOIN tblbreed ON tblquote.Breed = tblbreed.BreId WHERE (tblcn.valEn LIKE "%%" OR User LIKE "%%" OR tblcompany.valEn LIKE "%%" OR Plant LIKE "%%" OR tblcuts.valEn LIKE "%%" OR tblcattle.valEn LIKE "%%" OR tblbreed.ValEn LIKE "%%" ) ORDER BY qDate , referer: http://localhost:8081/quotes.agro_equity/AdminDataQuoteAdmin.php
[Mon Feb 01 11:46:52.458899 2021] [php7:notice] [pid 5684:tid 1520] [client ::1:53627] SELECT * FROM tblquote LEFT OUTER JOIN tblcn ON tblquote.Cn = tblcn.CnId LEFT OUTER JOIN tblcompany ON tblquote.Company = tblcompany.CompId LEFT OUTER JOIN tblcuts ON tblquote.Cut = tblcuts.Cutid LEFT OUTER JOIN tblcattle ON tblquote.Cattle = tblcattle.CatId LEFT OUTER JOIN tblbreed ON tblquote.Breed = tblbreed.BreId WHERE (tblcn.valEn LIKE "%%" OR User LIKE "%%" OR tblcompany.valEn LIKE "%%" OR Plant LIKE "%%" OR tblcuts.valEn LIKE "%%" OR tblcattle.valEn LIKE "%%" OR tblbreed.ValEn LIKE "%%" ) ORDER BY qDate , referer: http://localhost:8081/quotes.agro_equity/AdminDataQuoteAdmin.php
[Mon Feb 01 11:47:03.499044 2021] [php7:error] [pid 5684:tid 1520] [client ::1:53643] PHP Fatal error: Uncaught Error: Class 'phpoffice\\phpspreadsheet\\Spreadsheet' not found in C:\\xampp\\htdocs\\quotes.agro_equity\\quoteadmin_import.php:19\nStack trace:\n#0 {main}\n thrown in C:\\xampp\\htdocs\\quotes.agro_equity\\quoteadmin_import.php on line 19, referer: http://localhost:8081/quotes.agro_equity/AdminDataQuoteAdmin.php
[Mon Feb 01 11:47:05.914076 2021] [php7:notice] [pid 5684:tid 1528] [client ::1:53644] SELECT * FROM tblquote LEFT OUTER JOIN tblcn ON tblquote.Cn = tblcn.CnId LEFT OUTER JOIN tblcompany ON tblquote.Company = tblcompany.CompId LEFT OUTER JOIN tblcuts ON tblquote.Cut = tblcuts.Cutid LEFT OUTER JOIN tblcattle ON tblquote.Cattle = tblcattle.CatId LEFT OUTER JOIN tblbreed ON tblquote.Breed = tblbreed.BreId WHERE (tblcn.valEn LIKE "%%" OR User LIKE "%%" OR tblcompany.valEn LIKE "%%" OR Plant LIKE "%%" OR tblcuts.valEn LIKE "%%" OR tblcattle.valEn LIKE "%%" OR tblbreed.ValEn LIKE "%%" ) ORDER BY qDate , referer: http://localhost:8081/quotes.agro_equity/AdminDataQuoteAdmin.php
Les agrego mi código como imagen para que puedan ver el subdirectorio vendor
autoload.php
tiene en un array el llamado a la clase que quieres usar cierto?, de ser así prueba moviendo antes deluse
la línea donde hacesrequire
de dicho archivo