PHPackages                             jaza/drupal-integration-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. [Framework](/categories/framework)
4. /
5. jaza/drupal-integration-bundle

ActiveSymfony-bundle[Framework](/categories/framework)

jaza/drupal-integration-bundle
==============================

A Drupal integration bundle for Symfony2.

7211PHP

Since Jul 12Pushed 12y ago1 watchersCompare

[ Source](https://github.com/Jaza/DrupalIntegrationBundle)[ Packagist](https://packagist.org/packages/jaza/drupal-integration-bundle)[ RSS](/packages/jaza-drupal-integration-bundle/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Symfony2 Drupal Integration Bundle
==================================

[](#symfony2-drupal-integration-bundle)

This bundle lets you render a Symfony2 web app via Drupal 7. It also provides helpers for performing access control on a Symfony route, based on Drupal authentication and Drupal user roles. Plus a few other Symfony-Drupal integration helper methods.

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

[](#installation)

1 Add to the 'require' section of composer.json:

```
    "require" : {
        "jaza/drupal-integration-bundle": "1.0.*@dev",
    }

```

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

```
    $bundles = array(
        // ...
        new Jaza\DrupalIntegrationBundle\JazaDrupalIntegrationBundle(),
    );
```

Configuration
-------------

[](#configuration)

1 Add required config values to 'parameters.yml' file (or equivalent):

```
parameters:
    # ...
    drupal_root: /path/to/drupal
    drupal_base_url: 'http://drupal.baseurl'

```

2 Add various optional config values to 'parameters.yml' file (or equivalent):

```
parameters:
    # ...
    drupal_is_embedded: true
    drupal_menu_active_item: node/123
    drupal_wysiwyg_input_format_id: full_html
    drupal_css_includes: [/path/to/file1.css, /path/to/file2.css]
    drupal_get_author_username_methodname: getAuthorUsername
    drupal_get_author_uid_methodname: getAuthorUid
    drupal_admin_roles: [administrator]
    drupal_homelink_route: foo__default_index
    drupal_homelink_text: 'Foo home'

```

Usage
-----

[](#usage)

Create a controller in your bundle

```
namespace YOURNAME\YOURBUNDLE\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{

    public function indexAction()
    {
        $title = 'Foo hoo';

        // Get the Drupal integration service and bootstrap Drupal
        $drupalIntegration = $this->container->get('drupal_integration');
        $drupalIntegration->bootstrapDrupal();

        // Throw a Symfony AccessDeniedException if the current
        // Drupal user is not logged-in.
        $drupalIntegration->limitAccessToAuthenticatedUsers();

        // Easily check if the current response will be rendered via
        // Drupal or not - e.g. might have conditional template logic
        // based on this.
        $embedded = $this->container->getParameter('drupal_is_embedded');

        // Easily check if the current user is a Drupal administrator
        // or not - e.g. might show an 'admin only' link in the
        // template based on this.
        $isAdmin = $drupalIntegration->isAdmin();

        $engine = $this->container->get('templating');

        // Render the Symfony template output and store it in a variable
        // here, rather than returning the response directly to
        // Symfony as you'd normally do.
        $content = $engine->render('FooBundle:Default:index.html.twig', array(
            'title' => $title,
            'embedded' => $embedded,
            'is_admin' => $isAdmin,
        ));

        // Return a Symfony Response object - whether the content in
        // the response is output via Drupal or not depends on the
        // 'drupal_is_embedded' config value.
        return $drupalIntegration->getResponse($content);
    }

    public function adminAction()
    {
        $title = 'Administration';

        $drupalIntegration = $this->container->get('drupal_integration');
        $drupalIntegration->bootstrapDrupal();
        $drupalIntegration->limitAccessToAuthenticatedUsers();

        // Throw a Symfony AccessDeniedException if the current
        // Drupal user is not a Drupal administrator.
        $drupalIntegration->limitAccessToAdmin();

        // Load the WYSIWYG library configured by the Drupal Wysiwyg
        // module (must be enabled if using this).
        // Enable WYSIWYG for the textarea with the specified ID.
        $drupalIntegration->loadWysiwyg('foo_bundle_textblocktype_content');

        // You'll need to output this in a hidden field in the template,
        // next to the textarea, emulating Drupal's WYSIWYG / input
        // formats behavior.
        $inputFormatId = $drupalIntegration->getWysiwygInputFormatId();

        // Get a rendered link to this app's Symfony front page.
        // Useful for e.g. displaying a breadcrumb throughout
        // the Symfony app.
        $homeLink = $drupalIntegration->getHomeLink();

        $engine = $this->container->get('templating');

        $content = $engine->render('FooBundle:Default:admin.html.twig', array(
            'title' => $title,
            'home_breadcrumb' => $homeLink,
            'input_format_id' => $inputFormatId,
        ));

        return $drupalIntegration->getResponse($content);
    }

    public function viewAction(FooModel $fooModel)
    {
        $title = $fooModel->getTitle();

        $drupalIntegration = $this->container->get('drupal_integration');
        $drupalIntegration->bootstrapDrupal();
        $drupalIntegration->limitAccessToAuthenticatedUsers();

        // Throw a Symfony AccessDeniedException if the current
        // Drupal user is not a Drupal administrator or the
        // author of the specified object.
        $drupalIntegration->limitAccessToAdminOrAuthor($fooModel);

        $engine = $this->container->get('templating');

        $content = $engine->render('FooBundle:Default:view.html.twig', array(
            'title' => $title,
        ));

        return $drupalIntegration->getResponse($content);
    }
}
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/48bacf7c5aaf1df85016b3037d33ee889e8cfb3ec2f3509c3611ac7e2cfd778b?d=identicon)[Jaza](/maintainers/Jaza)

---

Top Contributors

[![Jaza](https://avatars.githubusercontent.com/u/79373?v=4)](https://github.com/Jaza "Jaza (2 commits)")

### Embed Badge

![Health badge](/badges/jaza-drupal-integration-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/jaza-drupal-integration-bundle/health.svg)](https://phpackages.com/packages/jaza-drupal-integration-bundle)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M836](/packages/laravel-socialite)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k38.6M289](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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