2017 © Pedro Peláez
 

symfony-bundle example-tweeter-core-bundle

Example Symfony2 bundle

image

llvdl/example-tweeter-core-bundle

Example Symfony2 bundle

  • Tuesday, February 25, 2014
  • by llvdl
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Llvdl Tweeter Core Bundle

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., (*1)

Installing

Add the following line to the require section in your composer.json file:, (*2)

"llvdl/example-tweeter-core-bundle": "dev-master", (*3)

and run composer update., (*4)

Add the following item to the $bundles array in registerBundles in AppKernel.php:, (*5)

new Llvdl\TweeterCoreBundle\TweeterCoreBundle(), (*6)

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., (*7)

To create the database tables, run:, (*8)

php app/console doctrine:schema:create, (*9)

To see the SQL queries to create the tables, but not execute them, add the --dump-sql flag:, (*10)

php app/console doctrine:schema:create --dump-sql, (*11)

Using the service

The bundle gives access to the tweet_service service, which has the following methods (see TweetService.php for details):, (*12)

Tweets are short messages created by a tweeter. When creating a tweet, the tweeter entity is created automatically if it does not already exist., (*13)

  • getRecentTweets
  • getRecentTweetsForTweeter
  • createTweet

To get a list of recent tweets in a controller:, (*14)

$service = $this->get('llvdl_tweeter_core.tweet_service');
$tweets = $service->getRecentTweets();
// do something with $tweets

The Versions