Get support for KnpLabs/KnpLastTweetsBundle
If you're new to LTH, please see our FAQ for more information on what it is we do.
Support Options
Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:
View Open IssuesTake a look to see if anyone else has experienced the same issue as you and if they managed to solve it.
Open an IssueMake sure to read any relevant guidelines for opening issues on this repo before posting a new issue.
Sponsor directlyCheck out the page and see if there are any options to sponsor this project or it's developers directly.
KnpLabs/KnpLastTweetsBundle
DEPRECATED
Unfortunately we decided to not maintain this project anymore (see why). If you want to mark another package as a replacement for this one please send an email to hello@knplabs.com.
KnpLastTweetsBundles
Warning
the bundle is working only with OAuth driver because of twitter api v.1 retirement
old users needs update abraham/twitteroauth
using composer update abraham/twitteroauth
This Symfony2 bundle will allow you to easily add a visual widget with the last tweets of the Twitter users to your page.
Note that tweets are transformed so that links are clickable.
Installation
Add KnpLastTweetsBundle in your composer.json
{
"require": {
"knplabs/knp-last-tweets-bundle": "*"
}
}
Register the bundle in your app/AppKernel.php
:
<?php
public function registerBundles()
{
$bundles = array(
// ...
new Knp\Bundle\LastTweetsBundle\KnpLastTweetsBundle(),
);
)
Buzz is required to use this bundle.
Usage
After installing the bundle, just do:
{% render "KnpLastTweetsBundle:Twitter:lastTweets" with {'username': 'knplabs'} %}
Or if you want use combined feed:
{% render "KnpLastTweetsBundle:Twitter:lastTweets" with {'username': ['knplabs', 'knplabsru']} %}
In that case tweets will be sorted by date.
Configuration
You will now have to configure the bundle to use one of the three available drivers.
Api driver
The simplest driver is the api
driver: it calls twitter API at each request.
# app/config.yml
knp_last_tweets:
fetcher:
driver: api
This is the default - you don't even have to add the previous config to app/config.yml
.
But it's obviously not peformant in production.
OAuth driver
The oauth_driver
uses InoriTwitterAppBundle.
First you should configure and install it.
Then you are freely to set it in config:
# app/config.yml
knp_last_tweets:
fetcher:
driver: oauth
Doctrine Cache driver
The doctrine_driver
uses DoctrineCache.
First you should configure and install it.
Then you are freely to set it in config:
# app/config.yml
knp_last_tweets:
fetcher:
driver: doctrine_cache
options:
cache_service: my_doctrine_cache_service #must be a valid doctrine cache
you could use LiipDoctrineCacheBundle for configuring your caches.
Zend_Cache driver
The zend_cache
driver uses Zend_Cache to cache the last tweets in a Zend_Cache_Backend (file, APC, memcached…).
You will need to install KnpZendCacheBundle first and configure it:
# app/config.yml
knp_zend_cache:
templates:
knp_last_tweets:
frontend:
name: Core
options:
lifetime: 300
automatic_serialization: true
backend:
name: File
options:
cache_dir: %kernel.root_dir%/cache/%kernel.environment%
knp_last_tweets:
fetcher:
driver: zend_cache
options:
cache_name: knp_last_tweets
method: api # or oauth
This will only call the twitter api after a minimum of 300 seconds.
The force-fetch command
Caching is good. But once in a while (well one every 5 minutes in the previous case and if you have a continuous flow a visits), one of your visitor will have to wait 2 unnecessary seconds while the server calls twitter API.
To avoid that, you should launch a cron job every 4 minutes which will force the fetching and caching of the new tweets
php app/console knp-last-tweets:force-fetch knplabs
This way, you will never make your visitors wait!
Array driver
The array
driver uses dummy data and does not call the twitter API.
It will return you 10 fake tweets - perfect in development.
# app/config.yml
knp_last_tweets:
fetcher:
driver: array
Recommendations
- Use the
array
driver in development (edit yourapp/config_dev.yml
file) - Use the
zend_cache
ordoctrine_cache
driver in production (edit yourapp/config.yml
file) - Use the
force-fetch
command in a cron job in production - Use HTTP caching if you know what this is about and if performance is really important to you!
- Use the
oauth
driver if you have problems with limits.
Advanced usage: HTTP caching
Please note that the following is not necessary: you should be perfectly fine without it.
You can use HTTP caching
and ESI
if you want the lastTweets
action to be rendered as an ESI tag.
This will improve performance by using a cached version of the whole rendered block - even in a dynamic page.
Follow the instructions on symfony.com and use the following code in your templates:
{% render "KnpLastTweetsBundle:Twitter:lastTweets" with {'username': ['knplabs', 'knplabsru'], 'age': 5}, {'standalone': true} %}
Credits
- Initial work has been done by KnpLabs
License
KnpLastTweetsBundle
is released under the MIT License. See the bundled LICENSE file for details.
Our Mission
We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.
From the Blog
Interesting Articles
-
Generating income from open source
Jun 23 • 8 min read
-
2023 State of OSS
Apr 23 • 45 min read ★
-
A funding experiment...
Aug 19 • 10 min read
-
But You Said I could
Aug 19 • 2 min read
Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated
p-e622a1a2