PHP code example of anfischer / cloner

1. Go to this page and download the library: Download anfischer/cloner 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/ */

    

anfischer / cloner example snippets

 php
$cloneService = new CloneService()

// $personModel->id === 1;
// gettype($personModel) === App\Person;

$clone = ($cloneService)->clone($personModel);

$persistedModel = (new PersistenceService)->persist($clone);
// or
$persistedModel = $clone->save();

// $persistedModel->id === 2

$map = $cloneService->getKeyMap();

// $map === [App\Person => [1 => 2]];

php artisan vendor:publish --provider="Anfischer\Cloner\ClonerServiceProvider"