1. Go to this page and download the library: Download nrslib/repository-supports 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/ */
nrslib / repository-supports example snippets
interface UserRepositoryInterface
{
function find(UserId $id): ?User;
function save(User $user): void;
}
use nrslib\RepositorySupports\FileRepository;
class FileUserRepository implements UserRepositoryInterface
{
use FileRepository;
function find(UserId $id): ?User
{
$user = $this->load($id->getValue());
if (is_null($user)) {
return null;
} else {
return $user;
}
}
public function save(User $user): void
{
$id = $user->getId()->getValue();
$this->store($id, $user);
}
}
use nrslib\RepositorySupports\FileRepositoryConfig;
class AppServiceProvider extends ServiceProvider
{
...
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// set directory here
$debugPersistenceDirectoryFullPath = storage_path("debug\\persistence");
FileRepositoryConfig::$basicDirectoryFullPath = $debugPersistenceDirectoryFullPath;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.