PHPackages                             dalv/wordbundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dalv/wordbundle

ActiveSymfony-bundle

dalv/wordbundle
===============

This is a Symfony2 Bundle helps you to read and write Word files, thanks to the PHPWord library

2.0.0(5y ago)016MITPHPPHP &gt;7.0

Since Jul 4Pushed 5y agoCompare

[ Source](https://github.com/vladdevops/WordBundle)[ Packagist](https://packagist.org/packages/dalv/wordbundle)[ Docs](https://github.com/GGGGino/WordBundle)[ RSS](/packages/dalv-wordbundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (15)Used By (0)

Symfony2 Word bundle
====================

[](#symfony2-word-bundle)

This bundle is a wrapper of the library [PHPOffice/PHPWord](https://github.com/PHPOffice/PHPWord).

For the complete reference look at the PHPWord Docs. [PHPWord Docs](https://github.com/PHPOffice/PHPWord)

License
-------

[](#license)

[![License](https://camo.githubusercontent.com/355ef41136ce991e2d980ebf52f04ee73589c7a9f2f7d1d311c7cac75f75a025/68747470733a2f2f706f7365722e707567782e6f72672f6c69756767696f2f457863656c42756e646c652f6c6963656e73652e706e67)](LICENSE)

Installation
------------

[](#installation)

**1** Add to composer.json to the `require` key

```
    $composer require ggggino/wordbundle
```

**2** Register the bundle in `app/AppKernel.php`

```
    $bundles = array(
        // ...
        new GGGGino\WordBundle\GGGGinoWordBundle(),
    );
```

Get started
-----------

[](#get-started)

- Create an empty object:

```
$phpWordObject = $this->get('phpword')->createPHPWordObject();
```

- Create a Word and write to a file given the object:

```
$writer = $this->get('phpword')->createWriter($phpWordObject, 'Word2007');
$writer->save('file.xls');
```

- Create a Word and create a StreamedResponse:

```
$writer = $this->get('phpword')->createWriter($phpWordObject, 'Word2007');
$response = $this->get('phpword')->createStreamedResponse($writer);
```

Not Only 'Word2007'
-------------------

[](#not-only-word2007)

The list of the types are:

1. 'Word2007'
2. 'ODText'
3. 'HTML'
4. 'PDF'
5. 'RTF'

Example
-------

[](#example)

You could find a lot of examples in the official PHPWord repository

### Create a new doc

[](#create-a-new-doc)

```
namespace YOURNAME\YOURBUNDLE\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;

class DefaultController extends Controller
{

    public function indexAction($name)
    {
        // ask the service for a Word2007
        $phpWordObject = $this->get('phpword')->createPHPWordObject();

        // Create a new Page
        $section = $phpWordObject->addSection();

        // Adding Text element to the Section having font styled by default...
        $section->addText(
            '"Learn from yesterday, live for today, hope for tomorrow. '
                . 'The important thing is not to stop questioning." '
                . '(Albert Einstein)'
        );

        // create the writer
        $writer = $this->get('phpword')->createWriter($phpWordObject, 'Word2007');
        // create the response
        $response = $this->get('phpword')->createStreamedResponse($writer);
        // adding headers
        $dispositionHeader = $response->headers->makeDisposition(
            ResponseHeaderBag::DISPOSITION_ATTACHMENT,
            'stream-file.doc'
        );
        $response->headers->set('Content-Type', 'application/msword');
        $response->headers->set('Pragma', 'public');
        $response->headers->set('Cache-Control', 'maxage=1');
        $response->headers->set('Content-Disposition', $dispositionHeader);

        return $response;
    }
}
```

### Edit a doc

[](#edit-a-doc)

In the template file(docx) variable should be declared as ${var1}, so in the template you can change "var1" value in this way:

```
$phpTemplateObject->setValue('var1', 'testValue');
```

Complete example

```
namespace YOURNAME\YOURBUNDLE\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;

class DefaultController extends Controller
{

    public function indexAction($name)
    {
      $fileName = ".../../test.docx";

        // ask the service for a Word2007
        $phpTemplateObject = $this->get('phpword')->createTemplateObject($fileName);

        $phpTemplateObject->setValue('test', 'testValue');

        $phpWordObject = $this->get('phpword')->getPhpWordObjFromTemplate($phpTemplateObject);

        // create the writer
        $writer = $this->get('phpword')->createWriter($phpWordObject, 'Word2007');
        // create the response
        $response = $this->get('phpword')->createStreamedResponse($writer);
        // adding headers
        $dispositionHeader = $response->headers->makeDisposition(
            ResponseHeaderBag::DISPOSITION_ATTACHMENT,
            'stream-file.docx'
        );
        $response->headers->set('Content-Type', 'application/msword');
        $response->headers->set('Pragma', 'public');
        $response->headers->set('Cache-Control', 'maxage=1');
        $response->headers->set('Content-Disposition', $dispositionHeader);

        return $response;
    }
}
```

Contribute
----------

[](#contribute)

1. fork the project
2. clone the repo
3. submit a PullRequest

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 92.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~117 days

Recently: every ~197 days

Total

12

Last Release

1949d ago

Major Versions

1.0.7 → 2.0.02021-01-06

PHP version history (6 changes)v1.0.0PHP &gt;=5.3.2

v1.0.2PHP &gt;=5.6|&gt;=7.0

v1.0.3PHP &gt;=5.6

1.0.7PHP &gt;=5.6|&gt;7.0

2.0.0PHP &gt;7.0

1.0.6.1PHP &gt;=5.5.9

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/362741?v=4)[Vlad Tamas](/maintainers/dalv)[@dalv](https://github.com/dalv)

---

Top Contributors

[![GGGGino](https://avatars.githubusercontent.com/u/3227441?v=4)](https://github.com/GGGGino "GGGGino (12 commits)")[![vladdevops](https://avatars.githubusercontent.com/u/16178744?v=4)](https://github.com/vladdevops "vladdevops (1 commits)")

---

Tags

bundleSymfony2wordoffice

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dalv-wordbundle/health.svg)

```
[![Health](https://phpackages.com/badges/dalv-wordbundle/health.svg)](https://phpackages.com/packages/dalv-wordbundle)
```

###  Alternatives

[stfalcon/tinymce-bundle

This Bundle integrates TinyMCE WYSIWYG editor into a Symfony2 project.

2692.9M24](/packages/stfalcon-tinymce-bundle)[liuggio/excelbundle

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

3776.4M10](/packages/liuggio-excelbundle)[data-dog/audit-bundle

Audit bundle for symfony2 and doctrine orm, logs any database change

141901.7k1](/packages/data-dog-audit-bundle)[dmishh/settings-bundle

Database centric Symfony configuration management. Global and per-user settings supported.

115254.9k1](/packages/dmishh-settings-bundle)[lexik/currency-bundle

This Symfony2 bundle provide a service and a Twig extension to convert and display currencies.

63234.9k1](/packages/lexik-currency-bundle)[fsi/admin-bundle

FSi Admin Bundle. Admin generator for Symfony.

5849.2k7](/packages/fsi-admin-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
