原諒這裏的表面跛腳。我正在使用共享主機,只能訪問cpanel,主機不願意代表我安裝composer或PHPWord。是否可以通過從github下載ZIP來安裝PHPWord?謝謝沒有作曲家的PHPWord安裝
回答
您可以在本地使用Composer,然後將文件上傳到服務器。
我問起這個位置:Using Composer locally then uploading files through FTP
基本上,如果你不能在服務器上運行作曲,本地使用它,然後將所需的文件複製到服務器。
你應該使用它的原因是因爲它會爲你下載依賴關係,而不必手動配置一些東西。這是作曲家:)
composer require phpoffice/phpword
Using version ^0.13.0 for phpoffice/phpword
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing pclzip/pclzip (2.8.2)
Downloading: 100%
- Installing phpoffice/common (v0.2.6)
Downloading: 100%
- Installing zendframework/zend-stdlib (2.4.13)
Downloading: 100%
- Installing zendframework/zend-validator (2.4.13)
Downloading: 100%
- Installing zendframework/zend-escaper (2.4.13)
Downloading: 100%
- Installing phpoffice/phpword (v0.13.0)
Downloading: 100%
下載PHpWord ZIP文件從這裏非常多的點:https://github.com/PHPOffice/PHPWord/archive/develop.zip
來源:: https://github.com/PHPOffice/PHPWord
PHPWord需要以下擴展名:
- PHP 5.3.3+
- XML分析器擴展
- 的Zend \逃避者部件
- 的Zend \ STDLIB部件
- 的Zend \驗證程序組件
- zip擴展(可選,用於寫和OOXML ODF)
- GD擴展(可選,用於增加圖象)
- XMLWriter的延伸部(可選的,用於寫和OOXML ODF)
- XSL擴展(可選,用於應用XSL樣式表到模板)
- DOMPDF庫(可選的,用來寫PDF)
例
PHPWord
庫的基本用法。 https://github.com/PHPOffice/PHPWord
謝謝。但任何想法如何獲得zend組件:Zend \ Escaper組件 Zend \ Stdlib組件 Zend \ Validator組件,因爲我沒有使用Zend框架? – Ojchris
是的,我一直這樣做。對於PHPWord,我會從GitHub下載zip文件並將src文件夾的內容移動到名爲「lib \ PhpOffice \ PhpWord」的目錄中。您將需要一個PHP類加載器。我總是使用它來自動加載,只要類是正確命名空間的,看起來就是這種情況。
$GLOBALS['class_path'] = array(__DIR__ . '/lib', __DIR__);
// Set-up class_path superglobal variable using php include_path as basis
if (!array_key_exists('class_path', $GLOBALS)) {
$GLOBALS['class_path'] = array();
foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) {
// substitute __DIR__ path for '.' instead
if ($path == '.') {
array_push($GLOBALS['class_path'], realpath(__DIR__));
continue;
}
array_push($GLOBALS['class_path'], realpath($path));
}
}
if (!function_exists('import')):
function import($package = '') {
if (empty($package)) {
trigger_error("Package path must be specified.", E_USER_ERROR);
}
$package_bits = explode('\\', $package);
$package_path = implode(DIRECTORY_SEPARATOR, $package_bits) . '.php';
foreach ($GLOBALS['class_path'] as $path) {
$file = $path . DIRECTORY_SEPARATOR . $package_path;
if (file_exists($file)) {
require_once($file);
$entity_name = implode('\\', $package_bits);
if (!(class_exists($entity_name, false) ||
interface_exists($entity_name, false)
|| trait_exists($entity_name, false))) {
$caller = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
trigger_error("Entity '" . $package . "' not found in file '" . $package_path . "' for import called in " .
$caller['file'] . " on line " . $caller['line'], E_USER_ERROR);
}
return;
}
}
}
endif;
spl_autoload_register('import');
設置你的$ GLOBALS [ 'CLASS_PATH']到 '的lib' 目錄的位置,一定要使用 '使用' 試圖實例PHPWord之前需要。
希望這會有所幫助!
謝謝你去了一英里。兩件事:走這條路1)任何想法如何獲得Zend組件:Zend \ Escaper組件 Zend \ Stdlib組件 因爲我沒有使用Zend框架,Zend \ Validator組件? 2)我正在使用codeigniter框架,我很感謝您關於如何使用類加載代碼的建議。謝謝 – Ojchris
我不會推薦這個。如果您按照我的答案使用Composer,則無需執行任何操作。它會爲您創建自動加載器。 – Andy
@Ojchris - 聽起來像你有1)想通了。至於2,CI有它自己的類加載器。我記得,它有一個目錄下的應用程序,你安裝自己的庫。我記得Zend的安裝以及我爲我所從事的網站下載的一些附加庫。不幸的是,我現在正在那個位置上空白。我會嘗試窺視我的一箇舊項目並查看該目錄的位置。 – Borgboy
在這裏,您可以在不下載作曲PHPWord: https://php-download.com/package/phpoffice/phpword
在這個網站是由作曲家網絡的所有庫,但你可以下載所有的人都沒有一個作曲家安裝。
- 1. 作曲家沒有安裝分依賴
- 2. phpword作曲家安裝到另一個目錄
- 3. 如何使用作曲家安裝PHPWord庫
- 4. 作曲家安裝
- 5. 作曲家安裝問題
- 6. 運行作曲家安裝
- 7. 安裝並與作曲家
- 8. 通過作曲家安裝
- 9. 作曲家安裝問題
- 10. 作曲家安裝錯誤
- 11. laravel安裝與作曲家
- 12. GitHub - 作曲家安裝Cakephp
- 13. 作曲家安裝和作曲家安裝之間的區別-o
- 14. 作曲家不能安裝,因爲插件API不匹配作曲家安裝
- 15. 沒有作曲家安裝棘輪的方法嗎?
- 16. 作曲家/ PHP:如何檢查作曲家包是否安裝?
- 17. php藝術家服務,作曲家更新/安裝..突然沒有工作
- 18. Windows 10,mamp,作曲家沒有安裝,但啓用了openssl&extension_dir
- 19. 作曲家創建項目沒有安裝Laravel 5.3
- 20. 作曲家沒有在Windows上安裝Fork CMS
- 21. 安裝作曲家的問題
- 22. 作曲家安裝不相關的庫
- 23. 最新的symfony安裝VS作曲家
- 24. 作曲家安裝的子文件夾
- 25. Semantic MediaWiki的作曲家安裝問題
- 26. Symfony的2.8:作曲家安裝錯誤
- 27. 作曲家要求未能安裝包
- 28. PHP作曲家安裝PHPUnit亞軍
- 29. 如何使用作曲家安裝SonataIntlBundle?
- 30. 作曲家安裝掛在ScriptHandler :: buildBootstrap
由於客戶端/工作是共享主機限制嗎?限制自己在第三節的時候聽起來並不好玩。 – castis
@castis主機剛說他們不支持它,客戶已經做了12個月的訂閱。不過,從一開始我並不認爲我需要額外的組件將word轉換爲pdf – Ojchris