Download the PHP package cunningsoft/achievement-bundle without Composer
On this page you can find all versions of the php package cunningsoft/achievement-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cunningsoft/achievement-bundle
More information about cunningsoft/achievement-bundle
Files in cunningsoft/achievement-bundle
Package achievement-bundle
Short Description Provides an achievement system for Symfony2
License MIT
Homepage https://github.com/dmecke/AchievementBundle
Informations about the package achievement-bundle
Installation
-
Add the following to your
composer.json
file: -
Run
composer update cunningsoft/achievement-bundle
to install the new dependencies. -
Register the new bundle in your
AppKernel.php
: -
Let your user entity implement the
Cunningsoft\AchievementBundle\Entity\UserInterface
: -
Map the interface to your user entity in your
config.yml
: -
Update your database schema:
-
Import routes:
-
Render the achievement list in your template:
-
Render the "achievement unlocked" layer at the bottom of your template:
-
Import js and css files:
-
Create a child bundle which holds all informations about your achievements
- Tell twig where to find your assets
Usage
For every achievement you want to use, go through these steps. This is an example showing how to give an achievement for posting a comment with at least 100 characters.
-
Add it to your achievement list
-
Create an event class as a container for the informations about the event
-
Create method to check for the achievement
-
Create achievement image
-
Add achievement description
-
Create event
// src/Acme/MainBundle/Controller/Comment.php // ... public function create() { // ... $this->get('event_dispatcher')->dispatch('comment_posted', new CommentEvent($comment)); } // ...
Now every time a comment is created (in your business logic) an event is triggered. Because of your achievements.yml the achievement system knows to listen for that event and trigger the according method in your AchievementListener. Now the method in your listener can check whether or not the requirements for one or more achievements are met and if so it triggers the booking of the achievement. Of course you may also utilize existing events or use the events for other purposes as well.
Changelog
-
0.2 (master)
- 0.1 First working version.
Notes
Please also visit my Open Source Browsergame Project Open Soccer Star.
All versions of achievement-bundle with dependencies
symfony/symfony Version ~2.3
doctrine/orm Version >=2.2.0
sensio/framework-extra-bundle Version >=2.1.0