example-silex.php 801 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Whoops - php errors for cool kids
  4. * @author Filipe Dobreira <http://github.com/filp>
  5. *
  6. * NOTE: Requires silex/silex, can be installed with composer:
  7. *
  8. * $ composer require silex/silex:*
  9. *
  10. * Run this example file with the PHP 5.4 web server with:
  11. *
  12. * $ cd project_dir
  13. * $ php -S localhost:8080
  14. *
  15. * and access localhost:8080/examples/example-silex.php through your browser
  16. *
  17. * Or just run it through apache/nginx/what-have-yous as usual.
  18. */
  19. require __DIR__ . '/../vendor/autoload.php';
  20. use Whoops\Provider\Silex\WhoopsServiceProvider;
  21. use Silex\Application;
  22. $app = new Application;
  23. $app['debug'] = true;
  24. if($app['debug']) {
  25. $app->register(new WhoopsServiceProvider);
  26. }
  27. $app->get('/', function() use($app) {
  28. throw new RuntimeException("Oh no!");
  29. });
  30. $app->run();