llvdl / example-tweeter-core-bundle
Example Symfony2 bundle
Installs: 22
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.2
- doctrine/doctrine-bundle: ~1.2
- doctrine/orm: ~2.2,>=2.2.3
Requires (Dev)
- doctrine/doctrine-fixtures-bundle: dev-master
- liip/functional-test-bundle: dev-master
This package is not auto-updated.
Last update: 2025-04-26 18:01:08 UTC
README
This is a sample Symfony2 bundle that contains a simple service to store and retrieve "tweets". The bundle consists of a service implementation, including a repository based on doctrine. It has no forms or controllers.
Installing
Add the following line to the require
section in your composer.json file:
"llvdl/example-tweeter-core-bundle": "dev-master"
and run composer update.
Add the following item to the $bundles
array in registerBundles
in
AppKernel.php:
new Llvdl\TweeterCoreBundle\TweeterCoreBundle()
Initiating the database
You should have the doctrine/orm package installed. Also a
database and user must be created. The configuration of the database properties
is probably at app/config/parameters.yml
.
To create the database tables, run:
php app/console doctrine:schema:create
To see the SQL queries to create the tables, but not execute them, add the
--dump-sql
flag:
php app/console doctrine:schema:create --dump-sql
Using the service
The bundle gives access to the tweet_service
service, which has the following
methods (see TweetService.php
for details):
Tweets are short messages created by a tweeter. When creating a tweet, the tweeter entity is created automatically if it does not already exist.
- getRecentTweets
- getRecentTweetsForTweeter
- createTweet
To get a list of recent tweets in a controller:
$service = $this->get('llvdl_tweeter_core.tweet_service');
$tweets = $service->getRecentTweets();
// do something with $tweets