Answers for "call controller symfony"

PHP
1

symfony call another controller

// OtherController::fancy($name, $color) will be executed
public function myAction($name)
{
    $response = $this->forward(
    	'App\Controller\OtherController::fancy',
    	array(
      		'name'  => $name,
        	'color' => 'green',
    	)
    );
    // ... further modify the response or return it directly
    return $response;
}
Posted by: Guest on March-24-2021
0

Basic Symfony Controller

// src/Controller/LuckyController.php
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class LuckyController
{
    /**
     * @Route("/lucky/number/{max}", name="app_lucky_number")
     */
    public function number(int $max): Response
    {
        $number = random_int(0, $max);

        return new Response(
            '<html><body>Lucky number: '.$number.'</body></html>'
        );
    }
}
Posted by: Guest on April-20-2021

Code answers related to "call controller symfony"

Browse Popular Code Answers by Language