mirror of
https://github.com/doctrine/rest.git
synced 2026-03-24 00:22:09 +01:00
38 lines
905 B
PHP
38 lines
905 B
PHP
<?php
|
|
|
|
require '/Users/jwage/Sites/doctrine2git/lib/Doctrine/Common/ClassLoader.php';
|
|
|
|
use Doctrine\REST\Client\Client,
|
|
Doctrine\REST\Client\EntityConfiguration,
|
|
Doctrine\REST\Client\Manager,
|
|
Doctrine\REST\Client\Entity,
|
|
Doctrine\Common\ClassLoader;
|
|
|
|
$classLoader = new ClassLoader('Doctrine\REST', __DIR__ . '/lib');
|
|
$classLoader->register();
|
|
|
|
$client = new Client();
|
|
|
|
$manager = new Manager($client);
|
|
$manager->registerEntity('User');
|
|
|
|
Entity::setManager($manager);
|
|
|
|
class User extends Entity
|
|
{
|
|
public $id;
|
|
public $username;
|
|
public $password;
|
|
|
|
public static function configure(EntityConfiguration $entityConfiguration)
|
|
{
|
|
$entityConfiguration->setUrl('http://localhost/rest/server.php');
|
|
$entityConfiguration->setName('user');
|
|
}
|
|
}
|
|
|
|
$user = User::find(9);
|
|
$user->username = 'teetertertsting';
|
|
$user->password = 'w00t';
|
|
$user->save();
|
|
print_r($user); |