Params

The Public params variable is a container that holds the values of any HTTP method request (GET, POST, PUT, DELETE, PATCH). You can access these values using either array notation ($params['valueName']) or object notation ($params->valueName), which makes it easy to retrieve the values from the request.

When you make a request to the server, the request parameters are passed to the server in the request body. The server then processes these parameters and returns the appropriate response. In Prisma PHP, you can access these request parameters using the Public params variable.

The params variable is an associative array that contains the request parameters. You can access the values of the request parameters using the key of the parameter. For example, if you have a request parameter named title, you can access its value using $params['title'] or $params->title.

Here is an example of how you can use the params variable to access the request parameters in Prisma PHP:

<php

  if ($isPost && isset($params->title)) {
      $todo = $prisma->todo->create([
          'data' => [
              'title' => $params->title
          ]
      ]);
      return $todo;
      exit;
  }
  
  ?>

In this example, we are checking if the request method is POST and if the request parameter title is set. If both conditions are met, we create a new todo item with the title provided in the request parameter and return the created todo item.