app.php 579 B

12345678910111213141516171819
  1. <?php
  2. use Silex\Application;
  3. use Bt51\Silex\Provider\GaufretteServiceProvider\GaufretteServiceProvider;
  4. $app = new Application();
  5. $app->register(new GaufretteServiceProvider(), array('gaufrette.adapter.class' => 'Local',
  6. 'gaufrette.options' => array(__DIR__ . '/media')));
  7. $app->get('/', function () use ($app) {
  8. try {
  9. $content = $app['gaufrette.filesystem']->read('/test.txt');
  10. } catch (\InvalidArgumentException $e) {
  11. return $app->abort(404, 'No file found');
  12. }
  13. return $content;
  14. });