This topic is locked
[SOLVED]

PHPWord wothout xomposer

11/10/2024 9:41:51 AM
PHPRunner General questions
P
Pietro Arcadio author

Hello everyone
I'm trying to use PHPword in phprunner but I have problems with the installation. I have no possibility to use composer but in the manual installation there is no autoloader.php file. How can I proceed?

C
cristi 11/10/2024

Latest (1.3) compiled version here

use vendor/autoload.php as entry point.

fhumanes 11/11/2024

Hello,

If you see examples of use of PHPWord in PHPRunner, you can see this example:

https://fhumanes.com/blog/impresos/documentos-e-informes-en-word/

You can download the projects and modify them to your liking. All are free.

Greetings,
fernando

P
Pietro Arcadio author 11/12/2024

thanks for the answers, I solved it by downloading phpword from the posted link.

Thanks also for the tutorial that I had already watched.

But now I have another problem, I can generate the Word file, but I can't get it to download automatically. I followed what is reported in the official documentation but there is no way. The file is generated and saved correctly, both on localhost when I compile the project, and on the production server. Do you suggest I mark this discussion as resolved and open a new one?

the error is identical to the one reported in this discussion:
https://github.com/PHPOffice/PHPWord/issues/482

Admin 11/12/2024

Instead of sending the file content to output ( which won't work, because this is a binary file ), you simply need to perform a redirect to the URL of the Word file on the web server.

We have an article that explains how you can, for instance, create and download a zip file:
https://xlinesoft.com/blog/2021/06/09/zip-and-download-selected-files/

P
Pietro Arcadio author 11/13/2024

Solved, everything works but I have only one problem, I can't set the language of the document, I get this error:

Fatal error: Uncaught Error: Class 'Language' not found

Ho usato questo codice

$phpWord->getSettings()->setThemeFontLang(new Language(Language::IT_IT));

Properties and all items work but with the language not set to IT all the words are underlined in red by the spell check

C
cristi 11/13/2024

That's because you didn't declared the class reference:

use PhpWord\Style\Language;

Path may need chages based on your implementation...