Skip to content

Commit c2172bf

Browse files
authored
Merge pull request #653 from wayofdev/feat/laravel-telescope
2 parents 0bfbedb + 207c453 commit c2172bf

File tree

3 files changed

+46
-16
lines changed

3 files changed

+46
-16
lines changed

docs/pages/services/laravel-telescope.mdx

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,43 @@ Install, telescope as usual, via Composer package manager:
2121
composer require laravel/telescope
2222
```
2323

24-
### Step 2: Publish Telescope Assets and run Migrations
24+
### Step 2: Publish Telescope Assets
2525

26-
After installing Telescope, publish its assets and migrations using the telescope:install Artisan command. After installing Telescope, you should also run the migrate command in order to create the tables needed to store Telescope's data:
26+
After installing Telescope, publish its assets and migrations using the `telescope:install` Artisan command.
2727

2828
```bash
2929
php artisan telescope:install
30+
```
31+
32+
### Step 3: Run Telescope Migrations trough Cycle-ORM-Adapter
33+
34+
After installing Telescope, you should also run the migrate command in order to create the tables needed to store Telescope's data, but as you are using Cycle ORM, you should avoid using default `php artisan migrate` command, and instead, do the following steps:
35+
36+
Edit `config/cycle.php` file and add the following code to the `tokenizer.directories` array:
3037

31-
php artisan migrate
38+
```php {7} filename="config/cycle.php"
39+
return [
40+
// ...
41+
'tokenizer' => [
42+
// ...
43+
'directories' => [
44+
app_path(),
45+
__DIR__ . '/../vendor/wayofdev/laravel-cycle-orm-adapter/src/Bridge/Telescope/Entities',
46+
],
47+
],
48+
],
3249
```
3350

34-
### Step 3: Add the CycleORM Query Watcher
51+
Run the following command to create the Telescope tables:
52+
53+
```bash
54+
php artisan cycle:migrate:init
55+
56+
php artisan cycle:orm:migrate --split --run
57+
```
58+
59+
60+
### Step 4: Add the CycleORM Query Watcher
3561

3662
Next, edit your `config/telescope.php` configuration file and add the following lines to the `watchers` array, right after the default`Watchers\QueryWatcher::class` line:
3763

@@ -59,7 +85,7 @@ return [
5985
];
6086
```
6187

62-
### Step 4: Add .env Configuration
88+
### Step 5: Add .env Configuration
6389

6490
Add the following configuration to your `.env` file:
6591

@@ -71,7 +97,7 @@ DB_USE_TELESCOPE_LOGGER=true
7197
...
7298
```
7399

74-
### Step 5: Access Laravel Telescope
100+
### Step 6: Access Laravel Telescope
75101

76102
Finally, you may access the Telescope dashboard via the `/telescope` route. Of course, don't forget to start your Laravel application:
77103

src/Bridge/Telescope/Entities/TelescopeEntry.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@
99
use Cycle\Annotated\Annotation\Table\Index;
1010
use DateTimeImmutable;
1111

12-
#[Index(columns: ['batch_id'])]
13-
#[Index(columns: ['family_hash'])]
14-
#[Index(columns: ['created_at'])]
15-
#[Index(columns: ['type', 'should_display_on_index'])]
12+
#[Index(columns: ['uuid'], unique: true, name: 'telescope_entries_uuid_unique')]
13+
#[Index(columns: ['batch_id'], name: 'telescope_entries_batch_id_index')]
14+
#[Index(columns: ['family_hash'], name: 'telescope_entries_family_hash_index')]
15+
#[Index(columns: ['created_at'], name: 'telescope_entries_created_at_index')]
16+
#[Index(columns: ['type', 'should_display_on_index'], name: 'telescope_entries_type_should_display_on_index_index')]
1617
#[Entity(table: 'telescope_entries')]
1718
class TelescopeEntry
1819
{
19-
#[Column(type: 'bigInteger', primary: true)]
20+
#[Column(type: 'primary')]
2021
public int $sequence;
2122

22-
#[Column(type: 'uuid', unique: true)]
23+
#[Column(type: 'uuid')]
2324
public string $uuid;
2425

2526
#[Column(type: 'uuid')]

src/Bridge/Telescope/Entities/TelescopeEntryTags.php renamed to src/Bridge/Telescope/Entities/TelescopeEntryTag.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
use Cycle\Annotated\Annotation\ForeignKey;
1010
use Cycle\Annotated\Annotation\Table\Index;
1111

12-
#[Index(columns: ['entry_uuid', 'tag'])]
12+
#[Index(columns: ['entry_uuid', 'tag'], unique: true)]
1313
#[Index(columns: ['tag'])]
1414
#[ForeignKey(target: TelescopeEntry::class, innerKey: 'entry_uuid', outerKey: 'uuid', action: 'CASCADE')]
15-
#[Entity(table: 'telescope_entry_tags')]
16-
class TelescopeEntryTags
15+
#[Entity(table: 'telescope_entries_tags')]
16+
class TelescopeEntryTag
1717
{
18-
#[Column(type: 'uuid', primary: true)]
18+
#[Column(type: 'primary')]
19+
public int $id;
20+
21+
#[Column(type: 'uuid')]
1922
public string $entryUuid;
2023

2124
#[Column(type: 'string')]

0 commit comments

Comments
 (0)