Symfony Controllers Action Value

I am new to the Symfony Framework. I am running Simple Project in Symfony. I define a function in the controller, for example

public function sampleAction()
{

}

What is the meaning of the action here?

+4
source share
3 answers

It is simply a convention (also in other environments such as ZF) to add the suffix "Action" to the name of these methods in controllers that are directly displayed through routes to make such actions more distinguishable from other methods.

Technically, the "Action" does not matter at all, i.e. the method does not behave differently because this suffix exists. You can also define a mode of action like this:

/**
 * @Route("/", name="homepage")
 *
 * @return \Symfony\Component\HttpFoundation\Response
 */
public function index()
{
    // ...
}

Symfony , .

+3

: - / . , / (, updateAction, deleteAction ..).

+1

What you used is a camel case representation of a function name

sampleAction is the name of the function.

there is no such thing that will be different sampleor Action.

0
source

Source: https://habr.com/ru/post/1618845/


All Articles