他们已经根据以下内容更新了插件并替换了一些共享类:https ://github.com/PHPOffice/PHPWord/releases 并且在升级 phpword 时,我遇到了这个错误。
A PHP Error was encountered
Severity: Error
Message: Class 'PhpOffice\Common\Text' not found
Filename: Element/Text.php
Line Number: 139
<?php
include_once(APPPATH."third_party/PHPWord/Autoloader.php");
if (!defined('BASEPATH'))
exit('No direct script access allowed');
use PhpOffice\PhpWord\Autoloader;
use PhpOffice\PhpWord\Settings;
Autoloader::register();
Settings::loadConfig();
class Test extends CI_Controller {
public function index() {
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->getCompatibility()->setOoxmlVersion(14);
$phpWord->getCompatibility()->setOoxmlVersion(15);
$section = $phpWord->addSection();
$html = '<p><strong style="font-weight: 600;"This is a heading</strong></p>
$filename = 'test.doc';
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save($filename);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
flush();
readfile($filename);
unlink($filename); // deletes the temporary file
exit;
}
}
我使用过composer,我想知道如何使用公共共享库:https ://github.com/PHPOffice/Common
请帮忙。