Created
May 5, 2020 01:29
-
-
Save anvodev/8eebefbd9980f09804e57e9fa387250b to your computer and use it in GitHub Desktop.
use Lucky service in a controller to return a lucky number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // src/Controller/DefaultController.php | |
| namespace App\Controller; | |
| use App\Lucky; | |
| use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | |
| use Symfony\Component\Routing\Annotation\Route; | |
| class DefaultController extends AbstractController | |
| { | |
| /** | |
| * @Route("/", name="default") | |
| */ | |
| public function index() | |
| { | |
| $lucky = new Lucky(); | |
| return $this->json(['number' => $lucky->getNumber()]); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment