PHP code example of voku / paris

1. Go to this page and download the library: Download voku/paris library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

voku / paris example snippets


/**
 * User: a sample user-class
 *
 * @property-read int    $id
 * @property-read string $first_name
 */
class User extends Model {
  public function tweets() {
      return $this->has_many('Tweet');
  }
  
  public function getId()
  {
    return $this->id;
  }
    
  public function getFirstName()
  {
    return $this->first_name
  }
}

/**
 * Tweet: a sample twitter-class
 *
 * @property-read int    $id
 * @property-read string $text
 */
class Tweet extends Model {
  
}

$user = Model::factory('User')
  ->where_equal('username', 'j4mie')
    ->find_one();
$user->first_name = 'Jamie';
$user->save();

$tweets = $user->tweets()->find_many();
foreach ($tweets as $tweet) {
  echo $tweet->text;
}