Skip to content

Commit 7b301bc

Browse files
committed
adding index route
1 parent 10d25ca commit 7b301bc

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

examples/symfony-app/config/routes.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ controllers:
33
path: ../src/Controller/
44
namespace: App\Controller
55
type: attribute
6+
7+
index:
8+
path: /
9+
methods: GET
10+
controller: App\Controller\IndexController::index
611

712
get_categories:
813
path: /categories
914
methods: GET
10-
controller: 'App\Controller\CategoryController::getCategories'
15+
controller: App\Controller\CategoryController::getCategories
1116

1217
get_products:
1318
path: /products
1419
methods: GET
1520
defaults:
16-
_controller: 'App\Controller\ProductController::getProducts'
21+
_controller: App\Controller\ProductController::getProducts
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace App\Controller;
4+
5+
use Psr\Log\LoggerInterface;
6+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7+
use Symfony\Component\HttpFoundation\Response;
8+
9+
//added just because New Relic<->Symfony needed it
10+
class IndexController extends AbstractController
11+
{
12+
private $logger;
13+
14+
public function __construct(LoggerInterface $logger)
15+
{
16+
$this->logger = $logger;
17+
}
18+
19+
/**
20+
* @Route("/", name="index")
21+
*/
22+
public function index(): Response
23+
{
24+
$this->logger->info('Homepage accessed');
25+
return new Response('Welcome to the PHP SDK Demo App');
26+
}
27+
}

0 commit comments

Comments
 (0)