Render the symfony profiler toolbar in your terminal.

Overview

sourceability/console-toolbar-bundle

Render the symfony profiler toolbar in your terminal.

Screen Shot 2021-05-18 at 17 52 13

Each panel links to the corresponding web profiler page. Make sure to use a terminal that support hyperlinks to leverage this feature.

Installation

Install the bundle using composer:

$ composer require --dev sourceability/console-toolbar-bundle

Enable the bundle by updating config/bundles.php:

return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    // ...
    FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['dev' => true, 'test' => true],
    Sourceability\ConsoleToolbarBundle\SourceabilityConsoleToolbarBundle::class => ['dev' => true, 'test' => true],
];

Configure the bundle in config/packages/{dev,test}/sourceability_console_toolbar.yaml:

sourceability_console_toolbar:
    toolbar:
        base_url: http://localhost:8200/ # for the iTerm2 hyperlinks
        hidden_panels:
            - config
            - form
            - validator
            - logger

By default, the profiler does not always run in the test environment. You can enable it like this:

--- a/config/packages/test/web_profiler.yaml
+++ b/config/packages/test/web_profiler.yaml
@@ -3,4 +3,4 @@ web_profiler:
     intercept_redirects: false

 framework:
-    profiler: { collect: false }
+    profiler: { enabled:true, collect: true, only_exceptions: false }

Also add web profiler routes in config/routes/test/web_profiler.yaml

web_profiler_wdt:
    resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
    prefix: /_wdt

web_profiler_profiler:
    resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
    prefix: /_profiler

Behat

This bundle becomes really useful when writing/debugging behat scenarios.

First enable the behat extension by adding the following to your behat configuration:

default:
    extensions:
        FriendsOfBehat\SymfonyExtension: ~
        Sourceability\ConsoleToolbarBundle\Behat\SymfonyToolbarExtension: ~

This will display the console toolbar whenever a new symfony profile is detected:

Screen Shot 2021-05-18 at 17 52 13

PHPUnit

Add the following to your phpunit.xml configuration:

false 4 ">
    <extensions>
        <extension class="Sourceability\ConsoleToolbarBundle\PHPUnit\ConsoleToolbarExtension">
            <arguments>
                <boolean>falseboolean> 
                <integer>4integer> 
            arguments>
        extension>
    extensions>

Screen Shot 2021-05-18 at 17 46 52

Console

bin/console now has a new global option --toolbar:

Screen Shot 2021-05-18 at 18 02 22

This feature requires sourceability/instrumentation-bundle with the following configuration:

sourceability_instrumentation:
    profilers:
        symfony:
            enabled: true
    listeners:
        command:
            enabled: true
Comments
  • Kernel boot time ahead of CSV

    Kernel boot time ahead of CSV

    I was trying this bundle, without success.

    Upon debugging i figured the profiles are filtered out based on kernel boot time (which theoretically makes sense :))

    First run:

    ^ "Profile: 2022-07-12 12:25:36"
    ^ "Kernel:  2022-07-12 12:26:21"
    

    Second run:

    ^ "Profile: 2022-07-12 12:26:22"
    ^ "Kernel:  2022-07-12 12:26:28"
    ^ "Profile: 2022-07-12 12:25:36"
    ^ "Kernel:  2022-07-12 12:26:28"
    

    Im not entirely sure why profiles are stored first :thinking: nor do i have another solution, but perhaps food for thought.

    opened by ro0NL 3
  • Change dependency from Router to RouterInterface

    Change dependency from Router to RouterInterface

    This patch fixes an error when the symfony router is overridden:

    Symfony\Component\Debug\Exception\FatalThrowableError^ {#8
      -originalClassName: "TypeError"
      #message: "Sourceability\ConsoleToolbarBundle\Console\ProfilerToolbarRenderer::__construct(): Argument #1 ($router) must be of type Symfony\Component\Routing\Router, EmmaCare\Shared\Service\Router given, called in /tmp/symfony/chat/local/Container1eAVnW7/getSourceability_ConsoleToolbar_Console_ProfilerToolbarRendererService.php on line 9"
      #code: 0
      #file: "./vendor/sourceability/console-toolbar-bundle/src/Console/ProfilerToolbarRenderer.php"
      #line: 71
      #severity: E_RECOVERABLE_ERROR
      trace: {
        ./vendor/sourceability/console-toolbar-bundle/src/Console/ProfilerToolbarRenderer.php:71 { …}
        /tmp/symfony/chat/local/Container1eAVnW7/getSourceability_ConsoleToolbar_Console_ProfilerToolbarRendererService.php:9 {
          require^
          › 
          › return $this->services['sourceability.console_toolbar.console.profiler_toolbar_renderer'] = new \Sourceability\ConsoleToolbarBundle\Console\ProfilerToolbarRenderer(($this->services['router'] ?? $this->getRouterService()), ($this->services['profiler'] ?? $this->getProfilerService()), ($this->services['twig'] ?? $this->getTwigService()), $this->parameters['data_collector.templates'], [0 => 'config', 1 => 'form', 2 => 'validator', 3 => 'logger'], 30);
          › 
          arguments: {
            $router: EmmaCare\Shared\Service\Router {#8581 …}
            $profiler: Symfony\Component\HttpKernel\Profiler\Profiler {#9514 …}
            $twig: Twig\Environment {#10540 …}
            $templates: array:23 [ …23]
            $hiddenPanels: array:4 [ …4]
            $maxColumnWidth: 30
          }
        }
        /tmp/symfony/chat/local/Container1eAVnW7/srcApp_KernelLocalDebugContainer.php:192 { …}
        /tmp/symfony/chat/local/Container1eAVnW7/getSourceability_ConsoleToolbar_EventListener_ConsoleToolbarListenerService.php:9 { …}
        /tmp/symfony/chat/local/Container1eAVnW7/srcApp_KernelLocalDebugContainer.php:192 { …}
        /tmp/symfony/chat/local/Container1eAVnW7/srcApp_KernelLocalDebugContainer.php:709 { …}
        ./vendor/symfony/event-dispatcher/EventDispatcher.php:279 { …}
        ./vendor/symfony/event-dispatcher/EventDispatcher.php:90 { …}
        ./vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:334 { …}
        ./vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:162 { …}
        ./vendor/symfony/console/Application.php:1042 { …}
        ./vendor/symfony/framework-bundle/Console/Application.php:97 { …}
        ./vendor/symfony/console/Application.php:273 { …}
        ./vendor/symfony/framework-bundle/Console/Application.php:83 { …}
        ./vendor/symfony/console/Application.php:149 { …}
        ./bin/console:39 { …}
      }
    }
    
    
    opened by rodion-k 3
  • Assert error

    Assert error

    After upgrading to 0.1.4 I am getting an error when running console command with --toolbar option:

    In ProfilerToolbarRenderer.php line 148:
                                                                   
      [Symfony\Component\Debug\Exception\FatalThrowableError (1)]  
      assert($fillCount > 0)                                       
                                                                   
    
    Exception trace:
      at /app/vendor/sourceability/console-toolbar-bundle/src/Console/ProfilerToolbarRenderer.php:148
     assert() at /app/vendor/sourceability/console-toolbar-bundle/src/Console/ProfilerToolbarRenderer.php:148
     Sourceability\ConsoleToolbarBundle\Console\ProfilerToolbarRenderer->renderRow() at /app/vendor/sourceability/console-toolbar-bundle/src/Console/ProfilerToolbarRenderer.php:121
     Sourceability\ConsoleToolbarBundle\Console\ProfilerToolbarRenderer->render() at /app/vendor/sourceability/console-toolbar-bundle/src/EventListener/ConsoleToolbarListener.php:107
     Sourceability\ConsoleToolbarBundle\EventListener\ConsoleToolbarListener->onTerminate() at /app/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:126
     Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke() at /app/vendor/symfony/event-dispatcher/EventDispatcher.php:264
     Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() at /app/vendor/symfony/event-dispatcher/EventDispatcher.php:239
     Symfony\Component\EventDispatcher\EventDispatcher->callListeners() at /app/vendor/symfony/event-dispatcher/EventDispatcher.php:73
     Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at /app/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:168
     Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch() at /app/vendor/symfony/console/Application.php:1042
     Symfony\Component\Console\Application->doRunCommand() at /app/vendor/symfony/framework-bundle/Console/Application.php:97
     Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /app/vendor/symfony/console/Application.php:273
     Symfony\Component\Console\Application->doRun() at /app/vendor/symfony/framework-bundle/Console/Application.php:83
     Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /app/vendor/symfony/console/Application.php:149
     Symfony\Component\Console\Application->run() at /app/bin/console:39
    
    
    opened by rodion-k 2
  • Fix Symfony 6 bug in Configuration

    Fix Symfony 6 bug in Configuration

    Symfony 6 requires the package and version parameters to be set when calling setDeprecated. This updates the file to name both this bundle and the earliest version where the deprecation was introduced.

    opened by magikid 0
  • Add full_stack variable

    Add full_stack variable

    Symfony 5.4 crashing when running behat tests because the full_stack variable doesn't exist and get passed to toolbar.html.twig

    See the addition of the variable in the web-profile-bundle

    The if call in the template fails

    {% if full_stack %}
    

    Note, the IDE didn't want to recognize FullStack::class as an existing class, so I went with Symfony\Bundle\FullStack (which is the class's full path) instead.

    Testing locally, this fix allowed my behat tests to run again

    opened by mbadolato 0
  • browser support

    browser support

    Here's a rough idea:

    When behat drives/runs a browser like chrome, it could be interesting to have screenshots/previews printed in the terminal.

    Or links to "page snapshots" or something.

    opened by adrienbrault 0
  • dump in profiler

    dump in profiler

    @adrienbrault first of all amazing work!!!

    I have a little doubt, is there any way to make the dump() go out through the profiler?

    Thank you so much!

    <?php
    
    namespace App\Command;
    
    use Sourceability\Instrumentation\Profiler\ProfilerInterface;
    use Symfony\Component\Console\Command\Command;
    use Symfony\Component\Console\Input\InputArgument;
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    
    class PagerFantaCommand extends Command
    {
    
        /**
         * @var ProfilerInterface
         */
        private $profiler;
    
        public function __construct(ProfilerInterface $profiler)
        {
            parent::__construct();
    
            $this->profiler = $profiler;
        }
    
        protected function configure()
        {
    
            $this
                ->setName('app:pager:fanta');
    
        }
    
        protected function execute(InputInterface $input, OutputInterface $output): int
        {
    
            $this->profiler->start('pagerFanta');
    
            dump('hi world!');
    
            $this->profiler->stop();
    
            return 0;
        }
    
    }
    
    opened by oscarpedrero 2
Owner
null
PHP's best friend for the terminal.

Running PHP from the command line? CLImate is your new best bud. CLImate allows you to easily output colored text, special formats, and more. Installa

The League of Extraordinary Packages 1.8k Dec 30, 2022
I gues i tried to make a shell that's looks like a terminal in single php file

php-shell-gui Terms of service This tool can only be used for legal purposes. You take full responsibility for any actions performed using this. The o

Squar3 4 Aug 23, 2022
tin is a PHP code highlighter for the terminal.

tin tin is a PHP code highlighter for the terminal. Installation Requires PHP 8.0.0+ You can install the package via composer: composer require felixd

Felix Dorn 15 Oct 7, 2022
Hentai Bash - This is the core of Hentai Terminal, responsible for the basic functions and commands

Hentai Bash - This is the core of Hentai Terminal, responsible for the basic functions and commands. It is mainly used for writing and executing commands.

Hentai Group 1 Jan 26, 2022
Create a simple todo-list application with the basic PHP programming language implemented in the terminal

PHP-DASAR---simple-todo-list-app-with-terminal create a simple todo-list application with the basic PHP programming language implemented in the termin

Ahmad Wali Alchalidi 2 Sep 7, 2022
Supercharge your Symfony console commands!

zenstruck/console-extra A modular set of features to reduce configuration boilerplate for your commands: /** * Creates a user in the database. * *

Kevin Bond 29 Nov 19, 2022
ReactPHP Shell, based on the Symfony Console component.

Pecan Event-driven, non-blocking shell for ReactPHP. Pecan (/pɪˈkɑːn/) provides a non-blocking alternative to the shell provided in the Symfony Consol

Michael Crumm 43 Sep 4, 2022
🤖 GitHub Action to run symfony console commands.

Symfony Console GitHub Action Usage You can use it as a Github Action like this: # .github/workflows/lint.yml name: "Lint" on: pull_request: push

Nucleos 3 Oct 20, 2022
A powerful command line application framework for PHP. It's an extensible, flexible component, You can build your command-based application in seconds!

CLIFramework CLIFramework is a command-line application framework, for building flexiable, simple command-line applications. Commands and Subcommands

Yo-An Lin 428 Dec 13, 2022
👨🏻‍🚀 A command-line tool that gives you the Alpine Day 2021 schedule in your timezone. 🚀

Alpine Day Schedule a command-line tool that gives you the Alpine Day 2021 schedule in your timezone. ?? Quick start Requires PHP 7.4+ # First, instal

Nuno Maduro 11 Jun 10, 2021
Patrol is an elegant command-line tool that keeps your PHP Project's dependencies in check.

Patrol is an elegant command-line tool that keeps your PHP Project's dependencies in check. Installation / Usage Requires PHP 8.0+ First, install Patr

Nuno Maduro 237 Nov 14, 2022
Laracon Schedule a command-line tool that gives you the Laracon Online schedule in your timezone.

Laracon Schedule a command-line tool that gives you the Laracon Online schedule in your timezone. ?? Quick start Requires PHP 7.4+ # First, install: c

Nuno Maduro 101 Sep 16, 2022
Display your Laravel routes in the console, but make it pretty. 😎

Pretty Routes for Laravel Display your Laravel routes in the console, but make it pretty. ?? Installation You can install the package via composer: co

Alex 630 Dec 30, 2022
Backup your laravel database by a simple artisan command

Backup your laravel database by a simple artisan command This package will allow you to backup your laravel app database and you can also choose to se

Mohammed Omer 23 Feb 10, 2022
This command will guide you through upgrade your composer.json config rom version 1 to version 2.

Upgrade composer.json This command will guide you through upgrade your composer.json config rom version 1 to version 2. How to use: $ cd YOUR_PROJECT_

Ehsan Sabet 3 May 18, 2022
A CLI program that helps you check your endpoints by requesting the given servers and send a report message in any supported channel like Telegram

API Monitor A CLI program that help you check your endpoints by requesting the given servers and send a report message in any supported channel ( Tele

Hussein Feras 51 Aug 21, 2022
Takeout is a CLI tool for spinning up tiny Docker containers, one for each of your development environment dependencies.

Takeout Takeout is a CLI tool for spinning up tiny Docker containers, one for each of your development environment dependencies. It's meant to be pair

Tighten 1.4k Jan 2, 2023
Keep your .env.example file up to date

Envy Automate keeping your environment files in sync. How many times have you onboarded a new dev onto your team, only to have to spend ages debugging

Worksome 576 Jan 1, 2023
A Cli tool to save you time, and gives you the power to scaffold all of your models,controllers,commands

A Cli tool to save you time, and gives you the power to scaffold all of your models,controllers,commands... at once Installation You can install the p

Coderflex 16 Nov 11, 2022