Slim3.1 基本使用
<?php
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
require __DIR__ . '/vendor/autoload.php';
$container = new Slim\Container;
$container['filesystem'] = function($container) {
$adapter = new Local(__DIR__);
$filesystem = new Filesystem($adapter);
return $filesystem;
};
$app = new Slim\App($container);
$app->get('/', function($request, $response, $args) {
$filesystem = $this->get('filesystem');
return $filesystem->read('myFile.txt');
});
$app->run();