Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel Octane support #58

Open
osbre opened this issue Dec 22, 2021 · 3 comments
Open

Laravel Octane support #58

osbre opened this issue Dec 22, 2021 · 3 comments

Comments

@osbre
Copy link

osbre commented Dec 22, 2021

Tried to register it in the flush section, still shows first request all the time.

'flush' => [
    Fruitcake\TelescopeToolbar\ToolbarServiceProvider::class,
],
@osbre
Copy link
Author

osbre commented Dec 22, 2021

The possible problem is that this method always has the same $token value:

$token = $this->getDebugToken();

@bornemisza
Copy link
Contributor

I have found an "issue" which is Laravel Octane related, but not similar to the original issue.

If somone using start kit and installs the Octane and Toolbar as well, but not running view:clear, before starting Octane the first time, will found it self, that the icons are not loaded, just the @TTicon directive is shown. The main "issue" is that Octane automatically caches the views. (It does not make a difference, if you use the file watching option on Octane.) While running the Octane you cannot clear the view cache, so you have to stop the server first and clear the view cache after. If you clear the cache and start again the Octane server, the icons will appear now.

I'm not 100% sure, if the Toolbar should handle the view cache clearing when Octane is used, but I just thought maybe it'll help someone else if experiencing this icon problem.

@Viktor-V
Copy link

Viktor-V commented May 6, 2024

@bornemisza Thank you for your solution, but unfortunately it didn't help me. Here's my solution that I hope will help others who have encountered the same issue:

  1. Create a new provider
<?php

declare(strict_types=1);

namespace App\Providers;

use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;

class TelescopeToolbarServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        //
    }

    public function boot(): void
    {
        Blade::directive('ttIcon', static function ($expression) {
            $dir = \realpath(__DIR__ . '/../../vendor/fruitcake/laravel-telescope-toolbar/resources/icons');
            return "<?php echo file_get_contents('$dir/' . basename($expression) . '.svg'); ?>";
        });
    }
}
  1. Register it in bootstrap/providers.php
<?php

return [
    App\Providers\AppServiceProvider::class,
    App\Providers\TelescopeServiceProvider::class,
    App\Providers\TelescopeToolbarServiceProvider::class,
];

P.S. I've only tested this on Laravel 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants