Skip to content

Conversation

anabeto93
Copy link
Contributor

@anabeto93 anabeto93 commented Jul 2, 2025

On a hypervel app, the details below from running php artisan about

php artisan about

  Environment ......................................  
  Application Name ................... Campaigns_API  
  Hypervel Version ........................... 0.2.6  
  PHP Version ................................ 8.4.8  
  Swoole Version ............................. 6.0.2  
  Composer Version ........................... 2.8.9  
  Environment ................................ local  
  Debug Mode ............................... ENABLED  
  URL .................................... localhost  
  Timezone ..................................... UTC 

compared to a laravel app with the following details running the same php artisan about

 php artisan about

  Environment ......................................  
  Application Name ......................... MTN_API  
  Laravel Version .......................... 12.19.3  
  PHP Version ................................ 8.4.8  
  Composer Version ........................... 2.8.9  
  Environment ................................ local  
  Debug Mode ............................... ENABLED  
  URL ...................................... mtn-api  
  Maintenance Mode ............................. OFF  
  Timezone ..................................... UTC  
  Locale ........................................ en  

When you do a dd() you get two different outputs one being much more detailed.

A simple dd() of an array in Laravel

Screenshot 2025-07-02 at 8 33 50 PM

A simple dd() of an array in Hypervel

Screenshot 2025-07-02 at 8 33 07 PM

Given the impressive work @nunomaduro did on Laravel, this PR brings that additional experience from laravel where the dd() functiion method output includes the source file and the line number where it originates.

You can learn more about this here https://laravel-news.com/history-dd

Run of the Tests

Screenshot 2025-07-02 at 8 52 25 PM

@proilyxa
Copy link

proilyxa commented Jul 3, 2025

@anabeto93 hey! is it possible to add dd() to browser output?

@albertcht albertcht added the enhancement Improved feature or adjustments. label Jul 3, 2025
@anabeto93
Copy link
Contributor Author

@anabeto93 hey! is it possible to add dd() to browser output?

@proilyxa you raise a great point and unfortunately no. The html dumper is actually supposed to enhance this, but the problem does not originate from hypervel but actually from the hyperf framework that this is based on. Once you call a dd() during an http session, you've practically killed the server (or worker) and it needs to be restarted. You can find out more about the reasons here https://hyperf.wiki/3.1/#/en/testing?id=debugging-code

Works without using dd()

Screenshot 2025-07-03 at 5 36 00 PM

Works fine in console

Screenshot 2025-07-03 at 5 43 45 PM

Even during an http request, it dumps out to console instead of the browser

Screenshot 2025-07-03 at 5 45 42 PM

This current behaviour of hypervel or hyperf is more like how the laravel dump server behaves. More on this here https://beyondco.de/docs/laravel-dump-server/installation

The way I see it @proilyxa , this exists (or does not exist 🤣 ) in order to force you to practice TDD instead.

*
* @var array<string, string>
*/
protected $editorHrefs = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add type declarations for class properties if possible

*
* @return null|void|array{0: string, 1: string, 2: int|null}
*/
public function resolveDumpSource()
Copy link
Member

@albertcht albertcht Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add declarations for return type

*/
protected static $adjustableTraces = [
'symfony/var-dumper/Resources/functions/dump.php' => 1,
'Illuminate/Collections/Traits/EnumeratesValues.php' => 4,
Copy link
Member

@albertcht albertcht Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be adjusted to Hypervel namespace

*
* @var null|(callable(): (array{0: string, 1: string, 2: int|null}|null))|false
*/
protected static $dumpSourceResolver;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add type declaration and default value

* @param string $basePath
* @param string $compiledViewPath
*/
public function __construct($output, $basePath, $compiledViewPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use constructor property promotion here

'cli' == $format => CliDumper::register($basePath, $compiledViewPath),
'server' == $format => null,
$format && 'tcp' == parse_url($format, PHP_URL_SCHEME) => null,
default => in_array(PHP_SAPI, ['cli', 'phpdbg']) ? CliDumper::register($basePath, $compiledViewPath) : HtmlDumper::register($basePath, $compiledViewPath),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP_SAPI in Hypervel should always be cli?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm back. In that case, we wouldn't need the HtmlDumper

@albertcht
Copy link
Member

Hi @anabeto93 , thanks for your contribution! I left some comments mainly about coding styles and rules to make them fit with Hypervel framework. Could you please adjust them if possible?

@albertcht albertcht merged commit aecc2a1 into hypervel:main Aug 19, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improved feature or adjustments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants