我在unbuntu 16上安装了两个带有composer的软件包:
都已经安装好了,这是phpoffice的输出。
Using version ^1.5 for phpoffice/phpspreadsheet
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
- Installing markbaker/complex (1.4.7): Downloading (100%)
- Installing psr/simple-cache (1.0.1): Downloading (100%)
- Installing phpoffice/phpspreadsheet (1.5.2): Downloading (100%)
phpoffice/phpspreadsheet suggests installing mpdf/mpdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing dompdf/dompdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing jpgraph/jpgraph (Option for renderi ng charts, or including charts with PDF or HTML Writers)
Writing lock file
Generating autoload files对于这两种情况,我都在主页上使用了基本示例,例如phpoffice one (https://phpspreadsheet.readthedocs.io/en/develop/)。
<?php
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');
$writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx'); 在运行这个程序时,我在apache错误日志上得到了以下信息(在运行fpdi-tcpdf时得到了类似的错误日志)。
[Thu Dec 06 21:14:42.835498 2018] [:error] [pid 1582] [client 192.168.223.1:53200] PHP Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/custom/excel.php on line 3
[Thu Dec 06 21:14:42.835716 2018] [:error] [pid 1582] [client 192.168.223.1:53200] PHP Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='.:/usr/share/php') in /var/www/html/custom/excel.php on line 3发布于 2018-12-07 08:25:11
谢谢克里夫
我使用以下命令找到了供应商文件夹:
composer config --list --global然后被取代
require 'vendor/autoload.php'; 使用autoload.php的完整路径,而且它已经工作了。
https://stackoverflow.com/questions/53660014
复制相似问题