You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Shop;
  3. use Psr\Http\Message\ResponseInterface as Response;
  4. use Psr\Http\Message\ServerRequestInterface as Request;
  5. use Psr\Container\ContainerInterface;
  6. use Slim\Factory\AppFactory;
  7. use DI\Container;
  8. use Shop\DB\myDB;
  9. use Shop\View\Twig;
  10. use Shop\DB\Order;
  11. use Shop\Model\Order as OrderModel;
  12. require __DIR__ . '/../vendor/autoload.php';
  13. $container = new Container();
  14. AppFactory::setContainer($container);
  15. $app = AppFactory::create();
  16. $container->set('twig', function () {
  17. $twig = new Twig('../templates');
  18. return $twig;
  19. });
  20. $container->set(
  21. 'db',
  22. function () {
  23. $db = new myDB();
  24. return $db;
  25. }
  26. );
  27. $app->get("/orders/{client}/create", \Shop\Controller\ClientCreate::class . ':createGet');
  28. $app->post("/orders/{client}/create", \Shop\Controller\ClientCreate::class . ':createPost');
  29. // Route with optional params, see https://www.slimframework.com/docs/v4/objects/routing.html#how-to-create-routes section Optional segments
  30. $app->get('/orders', \Shop\Controller\Orders::class . ':orders');
  31. $app->get('/orders/{client}', \Shop\Controller\Orders::class . ':ordersArgs');
  32. $app->get("/order/{id}/create", \Shop\Controller\OrderCreate::class . ':createGet');
  33. $app->post("/order/{id}/create", \Shop\Controller\OrderCreate::class . ':createPost');
  34. $app->get('/order/{id}', \Shop\Controller\OrderID::class . ':orderID');
  35. $app->get('/customers', \Shop\Controller\Clients::class . ':clients');
  36. $app->run();