PHP code example of withinboredom / record
1. Go to this page and download the library: Download withinboredom/record 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/ */
withinboredom / record example snippets
use Withinboredom\Record;
class Person extends Record {
public function __construct(public readonly string $firstName, public readonly string $lastName) {
// validate here
}
public function __toString() : string{
return $this->firstName . ' ' . $this->lastName;
}
}
$person = new Person('John', 'Doe');
$friend = $person->with(firstName: 'Jane');
echo "$person is friends with $friend";
// output: John Doe is friends with Jane Doe