O'Reilly logo

CouchDB and PHP Web Development Beginner's Guide by Tim Juravich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — plugging the User object in

With our new User object in our system, we can easily plug it into our application code, and we should be up and running.

  1. Open up the index.php file, and change stdClass to User(). While we are at it, we can also remove $user->type = 'user' because that's now handled in our class:
    post('/signup', function($app) {
    $user = new User();
    
    $user->name = $app->form('name');
    $user->email = $app->form('email');
    $app->couch->post($user);
    }
    
  2. Adjust the Sag post statement so that we can pass our class in the JSON format:
    post('/signup', function($app) {
    $user = new User();
    $user->name = $app->form('name');
    $user->email = $app->form('email');
    $app->couch->post($user->to_json);
    
    }
    

What just happened?

We replaced the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required