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

dd() in laravel zero do not have show line number like laravel #449

Open
kocoten1992 opened this issue Jun 4, 2023 · 3 comments
Open

dd() in laravel zero do not have show line number like laravel #449

kocoten1992 opened this issue Jun 4, 2023 · 3 comments

Comments

@kocoten1992
Copy link

It was a very neat feature in laravel :)

And thank you for this OSS repo.

@owenvoke
Copy link
Member

owenvoke commented Jun 5, 2023

The output should have a caret (^) before the dump, which will allow you to click through to open the file / line number in your editor. However, if you want to replicate the experience of Laravel exactly, you should be able to add the following to your AppServiceProvider::register() method:

public function register(): void
{
    $basePath = $this->app->basePath();

    \Illuminate\Foundation\Console\CliDumper::register($basePath, null);
}

@kocoten1992
Copy link
Author

Thanks for the code + explaination, but it is not exactly the same yet:

// in laravel-zero + your code in register
// app/Commands/GenerateMatchingSentenceCommand.php
// in laravel
// app/Commands/GenerateMatchingSentenceCommand.php:14

The line number was missing (it was the best part!).

And since this is a really neat feature, do you think it deserve to be in laravel-zero by default?

@owenvoke
Copy link
Member

owenvoke commented Jun 6, 2023

Ok, that's my bad. I thought the compiled view path could be made null to skip it, however you'll need to use:

public function register(): void
{
    $basePath = $this->app->basePath();

    $compiledViewPath = $this->app['config']->get('view.compiled', \Illuminate\Support\Str::random());

    \Illuminate\Foundation\Console\CliDumper::register($basePath, $compiledViewPath);
}

So the problem is, if the path gets detected as starting with the compiled view path (e.g. '' for when it's null), then the line number gets ignored. If you're not using views at all (for something like Termwind), this path needs to be set to something random instead (like... Str::random(), or sys_get_temp_dir()). Otherwise it will remove the line number from all dumps.

I guess this could be added in to Laravel Zero, it's just a case of ensuring it's clean and won't cause any issues.

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

No branches or pull requests

2 participants