PHP code example of maplephp / dto
1. Go to this page and download the library: Download maplephp/dto 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/ */
maplephp / dto example snippets
$name = isset($data['user']['profile']['name'])
? ucfirst(strip_tags($data['user']['profile']['name']))
: 'Guest';
$name = $obj->user->profile->name
->strStripTags()
->strUcFirst()
->fallback('Guest')
->get();
echo $obj->article->tagline->strToUpper();
// Result: 'HELLO WORLD'
echo $obj->article->content->strExcerpt()->strUcFirst();
// Result: 'Lorem ipsum dolor sit amet...'
echo $obj->title->strSlug();
// Result: 'my-awesome-title'
echo $obj->filesize->numToFilesize();
// Result: '1.95 kb'
echo $obj->price->numRound(2)->numToCurrency("USD");
// Result: $1,999.99
echo $obj->created_at->clockFormat('d M, Y', 'sv_SE');
// Result: '21 augusti 2025'
echo $obj->created_at->clockIsToday();
// Result: true
echo $obj->heading->domTag("h1.title");
// Result: <h1 class="title">My Heading</h1>
echo $obj->title->domTag("h1.title")->domTag("header");
// Result: <header><h1 class="title">Hello</h1></header>
foreach ($obj->users->fetch() as $user) {
echo $user->firstName->strUcFirst();
}
$updated = $obj->shoppingList->replace([0 => 'Shampoo']);
print_r($updated->toArray());