B
B
BloodVIRUS2021-10-11 11:33:02
Yii
BloodVIRUS, 2021-10-11 11:33:02

How to properly implement FullRestApi on yii2?

Hello. I would like to learn how to work with yii2 correctly, as it is described in many places. For example, to get an object, a GET request is used, and if it is necessary to create the same object, it is sent to the same POST url. And if the object needs to be changed - PUT.
There is documentation: https://www.yiiframework.com/doc/guide/2.0/en/rest...
It describes how to implement fully REST using essentially a few lines of code .. And there everything is as it should be.
But the question is, how to implement this without ActiveController? Since, in fact, completely different behavior will be tied to actionIndex when GET POST PUT
Inside actionIndex, doing if (isPost isPut isGet) looks like a crutch. There must be some nice code separation..
I don't want to use ActiveController because I'm sure there will always be different logical chains. Maybe it will be possible to create records only for one group of users, and edit another, and when editing some more code to execute ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mylistryx, 2021-10-11
@Mylistryx

Probably more correctly at the level of routes.
'GET some' => '/site/index',
'PUT some' => '/site/create',
'POST some' => '/site/update'
....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question