Skip to content
This repository has been archived by the owner on Nov 21, 2017. It is now read-only.

3.0 #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
.idea
vendor
build/*
!build/phpcs.xml
!build/phpmd.xml
!build/sami-config.xml
build
18 changes: 13 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
language: php
php:
- 5.3
- 5.4
- 5.5

matrix:
fast_finish: true
include:
- php: 5.4
- php: 5.5
- php: 5.6
- php: 7
- php: hhvm
allow_failures:
- php: 7
- php: hhvm

script: ./vendor/bin/phpunit -c ./phpunit.xml.dist ./tests/fixtures
before_script:
- composer self-update
- composer install --verbose
- composer install --dev --prefer-source
111 changes: 61 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,89 @@
#Silex Provider for EventManager
#EventManager provider for Silex

[![Latest Stable Version](https://poser.pugx.org/phpextra/event-manager/v/stable.svg)](https://packagist.org/packages/phpextra/event-manager-silex-provider)
[![Total Downloads](https://poser.pugx.org/phpextra/event-manager-silex-provider/downloads.svg)](https://packagist.org/packages/phpextra/event-manager-silex-provider)
[![License](https://poser.pugx.org/phpextra/event-manager-silex-provider/license.svg)](https://packagist.org/packages/phpextra/event-manager-silex-provider)
[![Build Status](http://img.shields.io/travis/phpextra/event-manager-silex-provider.svg)](https://travis-ci.org/phpextra/event-manager-silex-provider)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/phpextra/event-manager-silex-provider/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/phpextra/event-manager-silex-provider/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/phpextra/event-manager-silex-provider/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/phpextra/event-manager-silex-provider/?branch=3.0)
[![GitTip](http://img.shields.io/gittip/jkobus.svg)](https://www.gittip.com/jkobus)

No configuration is needed.

This provider will replace your EventDispatcher class.
Default symfony events were not removed and have higher priority.
It means that PHPExtra event is always running after the sf event.
Default Symfony events were not removed and have higher priority.
It means that PHPExtra event is always running after Symfony event.

Below is a reference, to see how events from PHPExtra are mapped onto vanilla sf events.
All events are cancellable (propagationStop property in sf event).
Unlike in symfony, cancellable events are still sent to all listeners. This behaviour may change in
future release of event manager.
All events are cancellable using propagation flag set in symfony event.
Event will be triggered even if propagation will be stopped.
To see if event was cancelled, use `SilexEvent::isCancelled()` before taking any action.

## Symfony event mapping
**Unlike in Symfony, cancellable events are still sent to all listeners**.

kernel.request
PHPExtra\EventManager\Silex\Event\RequestEvent
Symfony\Component\HttpKernel\Event\GetResponseEvent
##Installation and usage

kernel.controller
PHPExtra\EventManager\Silex\Event\PreDispatchEvent
Symfony\Component\HttpKernel\Event\FilterControllerEvent
If you are using logger, it will be automatically injected into the event manager.
Every class can now be a listener.

kernel.view
PHPExtra\EventManager\Silex\Event\PostDispatchEvent
Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent
```php
#bootstrap.php

kernel.response
PHPExtra\EventManager\Silex\Event\ResponseEvent
Symfony\Component\HttpKernel\Event\FilterResponseEvent
$app = new Silex\Application(array('debug' => true));
$app->register(new \PHPExtra\EventManager\Silex\EventManagerProvider());

kernel.finish_request
PHPExtra\EventManager\Silex\Event\PostRequestEvent
Symfony\Component\HttpKernel\Event\FinishRequestEvent

kernel.terminate
PHPExtra\EventManager\Silex\Event\PostResponseEvent
Symfony\Component\HttpKernel\Event\PostResponseEvent
$em = $app['event_manager'];

##Installation and usage
$em->addListener(new \PHPExtra\EventManager\Listener\AnonymousListener(function(SilexEvent $event){
echo "Im in some Symfony KernelEvent !";
}));

If you are using logger, it will be automatically injected into the event manager.
Every class can now be a listener.
$em->addListener($app['my_controller']);
$em->addListener($app['mailer']);

$app = new Silex\Application(array('debug' => true));
$app->register(new \PHPExtra\EventManager\Silex\EventManagerProvider());
# etc ...
```

$em = $app['event_manager'];
##Exception handling

$em->addListener(new \PHPExtra\EventManager\Listener\AnonymousListener(function(RequestEvent $event){
echo "Im in RequestEvent (Sf GetResponseEvent)";
}));
Exceptions that will occur during an event are suppressed in production mode and **will not brake the event loop**.
In development, the event manager will break the event loop and throw an exception.

$em->addListener(new \PHPExtra\EventManager\Listener\AnonymousListener(function(SilexKernelEvent $event){
echo "Im in some Symfony KernelEvent !";
}));
```php
$em->setThrowExceptions(false); // suppress exceptions and continue event loop
```

$em->addListener($app['my_controller']);
##Integration with profiler and symfony's Stopwatch component

$em->addListener($app['mailer']);
Stopwatch is enabled when debug mode is on. In production EventManager uses NullStopwatch.

...
## Symfony event mapping

##Exception handling
```
kernel.request
PHPExtra\EventManager\Silex\Event\RequestEvent
Symfony\Component\HttpKernel\Event\GetResponseEvent

Exceptions that will occur during an event are suppressed in production mode.
In development, the event manager will break the event loop and re-throw all exceptions.
kernel.controller
PHPExtra\EventManager\Silex\Event\PreDispatchEvent
Symfony\Component\HttpKernel\Event\FilterControllerEvent

kernel.view
PHPExtra\EventManager\Silex\Event\PostDispatchEvent
Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent

$em->setThrowExceptions(false); // suppress exceptions and continue event loop
kernel.response
PHPExtra\EventManager\Silex\Event\ResponseEvent
Symfony\Component\HttpKernel\Event\FilterResponseEvent

kernel.finish_request
PHPExtra\EventManager\Silex\Event\PostRequestEvent
Symfony\Component\HttpKernel\Event\FinishRequestEvent

kernel.terminate
PHPExtra\EventManager\Silex\Event\PostResponseEvent
Symfony\Component\HttpKernel\Event\PostResponseEvent
```

##Contributing

Expand All @@ -78,14 +93,10 @@ To ensure a consistent code base, you should make sure the code follows
the [coding standards](http://symfony.com/doc/2.0/contributing/code/standards.html).
If you would like to help take a look at the list of issues.

##Requirements

See **composer.json** for a full list of dependencies.

##Authors

Jacek Kobus - <[email protected]>

## License information

See the file LICENSE.txt for copying permission.
See the file LICENSE.txt for copying permission.
5 changes: 0 additions & 5 deletions build.properties

This file was deleted.

Loading