Skip to content

Commit 93fe691

Browse files
committed
Updates demo:
1. Add var-dumper code highlight 2. Improves profiler report 3. Adds attachment for smtp
1 parent cea8d2e commit 93fe691

File tree

8 files changed

+10020
-7
lines changed

8 files changed

+10020
-7
lines changed

app/Mail/WelcomeMail.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace App\Mail;
56

67
use Illuminate\Bus\Queueable;
78
use Illuminate\Mail\Mailable;
9+
use Illuminate\Mail\Mailables\Attachment;
810
use Illuminate\Queue\SerializesModels;
911

1012
class WelcomeMail extends Mailable
1113
{
1214
//use Queueable, SerializesModels;
1315

14-
public function __construct()
15-
{
16-
}
16+
public function __construct() {}
1717

1818
/**
1919
* Build the message.
@@ -25,4 +25,11 @@ public function build()
2525
return $this
2626
->markdown('emails.welcome');
2727
}
28+
29+
public function attachments()
30+
{
31+
return [
32+
Attachment::fromPath(app()->resourcePath('images/logo.svg'))->as('logo'),
33+
];
34+
}
2835
}

app/Modules/Profiler/Common.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace App\Modules\Profiler;
56

7+
use App\MyService\MyService;
8+
69
trait Common
710
{
811
public function setupProfiler(): void
@@ -14,5 +17,8 @@ public function setupProfiler(): void
1417
/** @test */
1518
function profilerReport(): void
1619
{
20+
\usleep(10_000);
21+
22+
app(MyService::class)->call();
1723
}
1824
}

app/Modules/VarDump/Common.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ function varDumpBool(): void
3939
/** @test */
4040
function varDumpInt(): void
4141
{
42-
dump(4, 8, 15, 16, 23, 42);
42+
dump(
43+
four: 4,
44+
eight: 8,
45+
fifteen: 15,
46+
sixteen: 16,
47+
twentythree: 23,
48+
fortytwo: 42,
49+
);
4350
}
4451

4552
/** @test */
@@ -50,7 +57,29 @@ function varDumpObject(RandomPhraseGenerator $generator): void
5057
$object->funnyFact = $generator->generate('Buggregator');
5158

5259
dump($object);
53-
dump(ray());
60+
}
61+
62+
/** @test */
63+
function varDumpCode(RandomPhraseGenerator $generator): void
64+
{
65+
trap(
66+
sprintf(
67+
<<<PHP
68+
<?php
69+
70+
declare(strict_types=1);
71+
72+
final class Buggregator
73+
{
74+
public function dump(): string
75+
{
76+
return '%s';
77+
}
78+
}
79+
PHP,
80+
$generator->generate('Buggregator'),
81+
),
82+
)->code('php');
5483
}
5584

5685
/** @test */

app/MyService/MyService.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\MyService;
6+
7+
use App\Models\User;
8+
9+
final class MyService
10+
{
11+
public function __construct() {}
12+
13+
public function call(): array
14+
{
15+
$result = [];
16+
for ($i = 0; $i < 1_000; $i++) {
17+
$result[] = User::factory()->makeOne();
18+
}
19+
20+
return $result;
21+
}
22+
}

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"spiral-packages/profiler": "^1.0"
1717
},
1818
"require-dev": {
19+
"buggregator/trap": "^1.9",
1920
"fakerphp/faker": "^1.9.1",
2021
"mockery/mockery": "^1.4.2",
2122
"phpunit/phpunit": "^9.3.3"
@@ -55,7 +56,10 @@
5556
"config": {
5657
"optimize-autoloader": true,
5758
"preferred-install": "dist",
58-
"sort-packages": true
59+
"sort-packages": true,
60+
"allow-plugins": {
61+
"php-http/discovery": true
62+
}
5963
},
6064
"minimum-stability": "dev",
6165
"prefer-stable": true

0 commit comments

Comments
 (0)