J
J
jallvar2022-03-01 21:20:45
PHP
jallvar, 2022-03-01 21:20:45

Why don't attributes work in Symfony?

Hello. I installed symphony 6.
I make the first controller and the application is not going to .

I tried to transfer the attribute to the method, changed the attribute itself -

HomePageController does not work:

<?php

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

#[Route(path: '/homepage')]
class HomePageController extends AbstractController
{
    public function __invoke()
    {
        $this->json(['success' => true], Response::HTTP_OK);
    }
}


annotations.yaml
controllers:
    resource: ../../src/Controller/
    type: annotation

kernel:
    resource: ../../src/Kernel.php
    type: annotation


When I execute console cache:clear I get error 139
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 139
!!  
!!   // Clearing the cache for the dev environment with debug                       
!!   // true                                                                        
!!  
!!  Segmentation fault
!!  
Script @auto-scripts was called via post-install-cmd

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nickolas Lyzhov, 2022-03-10
@17_planet

Attributes are PHP . You must have version 8.0 or higher.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question