1

I try to run PhpWord on server but have issue.

autoload.php

<?php
function loadLibraries($class) {
    $path = __DIR__.'/lib/';
    require_once $path.$class.".php";
}

spl_autoload_register("loadLibraries");

?>

and here is my PHP script

zml.php

<?php
error_reporting(E_ALL);

require "autoload.php";


// Create a new PHPWord object

use \PhpOffice\PhpWord\PhpWord;

$phpWord = new PhpWord();

// Add a section to the document
$section = $phpWord->addSection();

// Add some text to the section
$section->addText('Hello, World!');

// Save the document
$filename = 'hello_world.docx';
$phpWord->save($filename);

echo "Word document '$filename' has been created.";

?>

Here is error:

Warning: require_once(/zmluvy/lib/PhpOffice\PhpWord\PhpWord.php): failed to open stream: No such file or directory in /zmluvy/autoload.php on line 4

Fatal error: require_once(): Failed opening required '/zmluvy/lib/PhpOffice\PhpWord\PhpWord.php' (include_path='.:/usr/share/pear/') in /zmluvy/autoload.php on line 4

Location of files:

autoload.php
/zmluvy/

zml.php
/zmluvy/

PhpWord.php
/zmluvy/lib/PhpOffice/PhpWord/


Any suggestions? Thanks
3
  • Have you run composer install on the server ? Commented Sep 25, 2023 at 23:41
  • @Pippo cant use ssh connection on server. Commented Sep 26, 2023 at 6:10
  • So you have to make sure that the phpWord package is installed on the server and possibly you have to do it manually Commented Sep 26, 2023 at 9:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.