example-silex.php 837 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. * within this project using the --dev flag:
  8. *
  9. * $ composer install --dev
  10. *
  11. * Run this example file with the PHP 5.4 web server with:
  12. *
  13. * $ cd project_dir
  14. * $ php -S localhost:8080
  15. *
  16. * and access localhost:8080/examples/example-silex.php through your browser
  17. *
  18. * Or just run it through apache/nginx/what-have-yous as usual.
  19. */
  20. require __DIR__ . '/../vendor/autoload.php';
  21. use Whoops\Provider\Silex\WhoopsServiceProvider;
  22. use Silex\Application;
  23. $app = new Application;
  24. $app['debug'] = true;
  25. if($app['debug']) {
  26. $app->register(new WhoopsServiceProvider);
  27. }
  28. $app->get('/', function() use($app) {
  29. throw new RuntimeException("Oh no!");
  30. });
  31. $app->run();