Skip to content

Commit

Permalink
adding index route
Browse files Browse the repository at this point in the history
  • Loading branch information
barbara79 committed Oct 22, 2024
1 parent 10d25ca commit 7b301bc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
9 changes: 7 additions & 2 deletions examples/symfony-app/config/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ controllers:
path: ../src/Controller/
namespace: App\Controller
type: attribute

index:
path: /
methods: GET
controller: App\Controller\IndexController::index

get_categories:
path: /categories
methods: GET
controller: 'App\Controller\CategoryController::getCategories'
controller: App\Controller\CategoryController::getCategories

get_products:
path: /products
methods: GET
defaults:
_controller: 'App\Controller\ProductController::getProducts'
_controller: App\Controller\ProductController::getProducts
27 changes: 27 additions & 0 deletions examples/symfony-app/src/Controller/IndexController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Controller;

use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;

//added just because New Relic<->Symfony needed it
class IndexController extends AbstractController
{
private $logger;

public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}

/**
* @Route("/", name="index")
*/
public function index(): Response
{
$this->logger->info('Homepage accessed');
return new Response('Welcome to the PHP SDK Demo App');
}
}

0 comments on commit 7b301bc

Please sign in to comment.