index.php 649 B

12345678910111213141516171819202122
  1. <?php
  2. use Lesson19\ProjectManager;
  3. use Pimple\Container as Pimple;
  4. use Pimple\Psr11\Container;
  5. use Symfony\Component\HttpFoundation\Request;
  6. require_once __DIR__ . '/vendor/autoload.php';
  7. $app = new Silex\Application();
  8. $container = new Container($dic = new Pimple());
  9. $dic[ProjectManager::NAME] = ProjectManager::create($container);
  10. /** @var \ProjectManager $projectsManager */
  11. $projectsManager = $container->get('projects_manager');
  12. $app->match('/projects', function (Request $req) use($projectsManager) {
  13. $data = json_decode($req->getContent());
  14. return $projectsManager->createProject($data->name, $data->description);
  15. });
  16. $app->run();