12345678910111213141516171819202122 |
- <?php
- use Lesson19\ProjectManager;
- 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[ProjectManager::NAME] = ProjectManager::create($container);
- /** @var \ProjectManager $projectsManager */
- $projectsManager = $container->get('projects_manager');
- $app->match('/projects', function (Request $req) use($projectsManager) {
- $data = json_decode($req->getContent());
- return $projectsManager->createProject($data->name, $data->description);
- });
- $app->run();
|