Download the PHP package knplabs/knp-last-tweets-bundle without Composer
On this page you can find all versions of the php package knplabs/knp-last-tweets-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package knp-last-tweets-bundle
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 [email protected].
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
Register the bundle in your app/AppKernel.php
:
Buzz is required to use this bundle.
Usage
After installing the bundle, just do:
Or if you want use combined feed:
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.
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:
Doctrine Cache driver
The doctrine_driver
uses DoctrineCache.
First you should configure and install it.
Then you are freely to set it in config:
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:
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.
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:
Credits
- Initial work has been done by KnpLabs
License
KnpLastTweetsBundle
is released under the MIT License. See the bundled LICENSE file for details.
All versions of knp-last-tweets-bundle with dependencies
symfony/framework-bundle Version >=2.0.0
kriswallsmith/buzz Version >=v0.5
twig/twig Version >=1.6.5
symfony/yaml Version *