We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

REST API

can somebody help me with this error ? "Trying to get property of non object". The error points to lines were is asign user_name , password.....birthday

  $app->post('/myapi/users', function () use ($app) {
        $user = $app->request->getJsonRawBody();

        $phql = "INSERT INTO Users (user_name, password, gender, screen_name, birthday) VALUES (:user_name:, :password:, :gender:,:screen_name:,:birthday:)";
        $status = $app->modelsManager->executeQuery($phql, array(
            'user_name' => $user->user_name,
            'password' => $user->password,
            'gender' => $user->gender,
            'screen_name' => $user->screen_name,
            'birthday' => $user->birthday

        ));

My guess is that you don't have modelsManager set as a service. Do you have something like in your code?

$app->set('modelsManager', function() {
      return new ModelsManager();
});

From the docs here: https://docs.phalcon.io/en/latest/api/Phalcon_Mvc_Model_Manager.html

Do a var_dump on the $user variable so as to determine whether getJsonRawBody() returned correct data for you.