123456789101112131415161718192021222324 |
- <?php
- use Lesson19\ProjectManager;
- use Lesson19\ProjectStore;
- use Pimple\Container as Pimple;
- use Pimple\Psr11\Container;
- use Symfony\Component\HttpFoundation\Request;
- require_once __DIR__ . '/vendor/autoload.php';
- $app = new Silex\Application();
- $container = new Container($dic = new Pimple());
- $dic[ProjectStore::NAME] = ProjectStore::instantiate($container);
- $dic[ProjectManager::NAME] = ProjectManager::instantiate($container);
- /** @var \ProjectManager $projectsManager */
- $projectsManager = $container->get(ProjectManager::NAME);
- $app->match('/projects', function (Request $req) use($projectsManager) {
- $data = json_decode($req->getContent());
- return $projectsManager->createProject($data->name, $data->description);
- });
- $app->run();
|