PHPackages                             goutte/wordpress-bundle - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. goutte/wordpress-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

goutte/wordpress-bundle
=======================

v0.1(13y ago)15393PHPPHP &gt;=5.3.3

Since Nov 19Pushed 12y ago3 watchersCompare

[ Source](https://github.com/Goutte/WordpressBundle)[ Packagist](https://packagist.org/packages/goutte/wordpress-bundle)[ RSS](/packages/goutte-wordpress-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

What is it ?
============

[](#what-is-it-)

This is a bridge between WordPress and Symfony2.

This bundle will allow you to :

- find published posts/pages
    - all of them
    - by slug
- find attachments by mime-type, specifically images

That's all !

Inspired (a lot!) by :

-
- and its active fork
-

I re-did the bundle from scratch because I wanted working and clean tests at all times. Plus, it's a learner's project.

You should not use this bundle, as using both WordPress AND Symfony2 is a bad practice, but until the [CMF](http://cmf.symfony.com) is media-ready this is a good enough alternative in some fast-food cases.

How to use
==========

[](#how-to-use)

1. Create your wordpress as usual
2. Add [this bundle](https://packagist.org/packages/goutte/wordpress-bundle) to your composer.json
3. Register this bundle in your AppKernel.php
4. Configure in app/config.yml

    ```
    goutte_wordpress:
        # WP tables prefix, default is 'wp_'
        table_prefix: wp_
    ```
5. Configure your parameters.yml to point towards the wordpress database

Usage examples
==============

[](#usage-examples)

You'll need the Entity Manager

```
$em = $this->get('doctrine')->getEntityManager(); // whichever way you're using to get the em
```

Posts
-----

[](#posts)

Will only fetch posts, not pages nor attachments. (see below on how to get those)

```
$postRepository = $em->getRepository('GoutteWordpressBundle:Post');

$posts = $postRepository->findPublished(); // finds all published posts

// finds a maximum of 5 published posts after omitting the first 3
$posts = $postRepository->findPublished(5,3);

// finds one post by its slug, or returns false
$post = $postRepository->findPublishedBySlug('hello-word');
```

Pages
-----

[](#pages)

```
$pageRepository = $em->getRepository('GoutteWordpressBundle:Page');

$pages = $pageRepository->findPublished(); // finds all published pages

// finds a maximum of 5 published pages after omitting the first 3
$pages = $pageRepository->findPublished(5,3);

// finds one page by its slug, or returns false
$page = $pageRepository->findPublishedBySlug('hello-word');
```

Images
------

[](#images)

```
