PHP code example of friendsofhyperf / telescope
1. Go to this page and download the library: Download friendsofhyperf/telescope 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/ */
friendsofhyperf / telescope example snippets
// config/autoload/listeners.php
return [
FriendsOfHyperf\Telescope\Listener\SetRequestLifecycleListener::class,
FriendsOfHyperf\Telescope\Listener\RequestHandledListener::class,
];
// config/autoload/middlewares.php
return [
'grpc' => [
FriendsOfHyperf\Telescope\Middleware\TelescopeMiddleware::class,
],
];
use FriendsOfHyperf\Telescope\Telescope;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Framework\Event\BootApplication;
use FriendsOfHyperf\Telescope\IncomingEntry;
class TelescopeInitListener implements ListenerInterface
{
public function listen(): array
{
return [
BootApplication::class,
];
}
public function process(object $event): void
{
// attach your own custom tags
Telescope::tag(function (IncomingEntry $entry) {
if ($entry->type === 'request') {
return [
'status:' . $entry->content['response_status'],
'uri:'. $entry->content['uri'],
];
}
});
// filter entry
Telescope::filter(function (IncomingEntry $entry): bool {
if ($entry->type === 'request'){
if ($entry->content['uri'] == 'xxxx') {
return false;
}
}
return true;
});
}
}
shell
php bin/hyperf.php vendor:publish friendsofhyperf/telescope
shell
php bin/hyperf.php migrate