Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install PHPWord library using composer

Tags:

php

I am trying to install PHPWord library of PHP using composer but i cant install.

I have tried to follow https://github.com/PHPOffice/PHPWord.

like image 615
Gurudutt Sharma Avatar asked May 30 '17 11:05

Gurudutt Sharma


People also ask

How do I install PhpWord?

PHPWord is installed via Composer. You just need to add dependency on PHPWord into your package. If you are a developer or if you want to help us with testing then fetch the latest branch for developers. Notice: all contributions must be done against the developer branch.


3 Answers

Run this command in the root of your project to add the dependency to composer.json and install the librarie:

composer require phpoffice/phpword
like image 144
T. AKROUT Avatar answered Oct 16 '22 19:10

T. AKROUT


Run this command in the root of your project $ composer require phpoffice/phpword

You will find vendor folder and 2 files composer.json and composer.lock in the root folder of your project.

Create a new file, index.php, in the root folder of the project(or some other filename). Copy paste the basic usage sample code provided in https://github.com/PHPOffice/PHPWord

Change the line require_once 'bootstrap.php'; to require_once 'vendor/autoload.php';

Run the new file created and then you can see the docx file created in the root folder of your project.

like image 42
Vinu Avatar answered Oct 16 '22 19:10

Vinu


You just need to add dependency on PHPWord into your package. just below code in your composer.json file

{
    "require": {
       "phpoffice/phpword": "v0.13.*"
    }
}

and then execute the below code from console

$ composer.phar install
like image 21
Narayan Avatar answered Oct 16 '22 21:10

Narayan