Installation: Add the package via Composer:
composer require aureka/disqus-bundle:dev-master
Register the bundle in config/bundles.php (Symfony 4+) or AppKernel.php (Symfony 3/2):
Aureka\DisqusBundle\AurekaDisqusBundle::class => ['all' => true],
Basic Configuration:
Add the minimal short_name to config/packages/aureka_disqus.yaml:
aureka_disqus:
short_name: 'your_disqus_shortname'
First Use Case:
Implement Disqusable on your entity (e.g., BlogPost) and use the disqus() Twig function in a template:
{{ disqus(blogPost) }}
Implement Disqusable:
Extend your entity (e.g., BlogPost) with getDisqusId() to uniquely identify threads:
class BlogPost implements Disqusable {
public function getDisqusId() {
return $this->slug; // or UUID, ID, etc.
}
}
Dynamic IDs:
Generate IDs on-the-fly (e.g., using uniqid() or UUID) if not persisted.
Thread Rendering:
Use {{ disqus(entity) }} in templates to embed Disqus threads. Place this after page content (Disqus requires DOM elements to exist).
Comment Count:
Add {{ disqus_count() }} to display comment counts (e.g., in search results or lists).
Enable SSO:
Configure config/packages/aureka_disqus.yaml:
aureka_disqus:
short_name: 'your_shortname'
sso:
enabled: true
api_key: '%env(DISQUS_API_KEY)%'
private_key: '%env(DISQUS_PRIVATE_KEY)%'
User Integration:
Implement DisqusUser on your User entity:
class User implements DisqusUser {
public function getDisqusId() {
return $this->id;
}
}
Authentication Hook:
Extend the bundle’s DisqusSSOListener or create a custom event subscriber to sync Symfony users with Disqus during login/logout.
disqus() in a fragment or Varnish if used frequently.Missing short_name:
Without short_name in config, Twig functions will throw errors. Validate this early.
SSO Misconfiguration:
api_key and private_key are correctly set in Disqus admin under Applications > Single Sign-On.Thread ID Collisions:
getDisqusId() must return unique, URL-safe strings (e.g., avoid spaces or special chars). Sanitize IDs if needed:
public function getDisqusId() {
return strtolower(str_replace(' ', '-', $this->title));
}
Script Loading Order:
Disqus scripts must load after the DOM elements they target. Place {{ disqus() }} near the end of your template or use {{ disqus()|raw }} with JavaScript defer.
Symfony 4+ Kernel Changes:
If upgrading from Symfony 3, ensure the bundle is registered in config/bundles.php (not AppKernel).
Check Console Errors:
Disqus scripts may fail silently. Inspect browser console for 404 errors (missing scripts) or ReferenceError (missing DISQUS global).
SSO Debugging:
Enable Disqus debug mode in your app settings to log SSO issues. Use bin/console debug:config aureka_disqus to verify config.
Custom Twig Functions:
Extend the bundle by overriding the DisqusTwigExtension or adding your own:
// src/Service/CustomDisqusExtension.php
class CustomDisqusExtension extends \Aureka\DisqusBundle\Twig\DisqusTwigExtension {
public function getFunctions() {
return array_merge(parent::getFunctions(), [
new \Twig\TwigFunction('custom_disqus', [$this, 'customDisqusMethod']),
]);
}
}
Event Listeners:
Subscribe to aureka.disqus.sso.login or aureka.disqus.sso.logout events to customize SSO behavior:
// src/EventListener/DisqusSSOListener.php
class DisqusSSOListener implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return [
'aureka.disqus.sso.login' => 'onSSOLogin',
];
}
}
Configuration Overrides:
Override bundle config via config/packages/override/aureka_disqus.yaml:
aureka_disqus:
sso:
enabled: false # Disable SSO for specific environments
dev environments:
# config/packages/dev/aureka_disqus.yaml
aureka_disqus:
sso:
enabled: false
How can I help you explore Laravel packages today?