php 如何调试 Laravel 框架?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23927561/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to debug Laravel framework?
提问by bromelio
I'm a newbie PHP programmer now casting an eye at frameworks, and among them Laravel sounds appealing to me as a beginner (somehow unfortunately because I've already invested in literature on Zend 2). However, debugging is important to me and from what I could find on the net, Laravel is hard to debug. I currently use Xdebug in Netbeans on native PHP code and wonder whether Laravel can be debugged in the same or a similar way? When I open a new Netbeans project I can select Symfony 2 or Zend 2, but there seems to be indeed no support for other frameworks like Laravel? If not, is there at least an equivalent debugging tool?
我是一名 PHP 新手程序员,现在正在关注框架,其中 Laravel 听起来对我初学者很有吸引力(不幸的是,因为我已经投资了有关 Zend 2 的文献)。然而,调试对我来说很重要,从我在网上找到的信息来看,Laravel 很难调试。我目前在 Netbeans 中对原生 PHP 代码使用 Xdebug,想知道 Laravel 是否可以以相同或类似的方式调试?当我打开一个新的 Netbeans 项目时,我可以选择 Symfony 2 或 Zend 2,但似乎确实不支持其他框架,例如 Laravel?如果没有,是否至少有一个等效的调试工具?
采纳答案by BlackHyman
Laravel has its own debugging system.You can use built in dd() function.And there are several packages that can be used to debug laravel projects.Here are some links and hope that it will be helpful for you.
Laravel 有自己的调试系统。你可以使用内置的 dd() 函数。还有几个包可以用来调试 Laravel 项目。这里有一些链接,希望对你有所帮助。
https://github.com/barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar
http://laravel.io/forum/02-04-2014-package-laravel-debugbar
http://laravel.io/forum/02-04-2014-package-laravel-debugbar
Thanks
谢谢
回答by leopinzon
Recently I came to discover this amazing plugin that allows you to dump variables, trace requests, executions, views, controllers, queries, profile memory, execution time, etc., everything related to the current rendered page. Very helpful :
最近我发现了这个神奇的插件,它允许你转储变量、跟踪请求、执行、视图、控制器、查询、配置文件内存、执行时间等,与当前呈现的页面相关的所有内容。很有帮助 :
https://laravel-news.com/laravel-debugbar
https://laravel-news.com/laravel-debugbar
You can install it via composer:
您可以通过 composer 安装它:
composer require barryvdh/laravel-debugbar --dev
Then add it to your service providers array in /config/app.php
然后将其添加到您的服务提供商数组中 /config/app.php
The Debugbar will start working inmediately if the debug mode is turned on: To do it so, you just need to modify in your config/app.php
or .env
file the debug_mode
to true.
如果打开调试模式,调试栏将立即开始工作:为此,您只需要在您的config/app.php
或.env
文件中修改debug_mode
为true。
If you wish to use the dump methods in the debugbar console, you need to include the alias to your /config/app.php
array:
如果您希望在调试栏控制台中使用转储方法,则需要在/config/app.php
数组中包含别名:
'Debugbar' => Barryvdh\Debugbar\Facade::class,
Now you can start dumping variables like this:
现在你可以开始像这样转储变量:
\Debugbar::info($variable);
Pretty cool plugin. Cheers!
很酷的插件。干杯!
回答by BuBy
laravel telescope
Laravel 望远镜
https://github.com/laravel/telescope
https://github.com/laravel/telescope
in laracast you can find even a episodie about it
在 laracast 你甚至可以找到关于它的一集
https://laracasts.com/series/laravel-from-scratch-2018/episodes/28
https://laracasts.com/series/laravel-from-scratch-2018/episodes/28
回答by barbushin
Also there is Google Chrome extension "PHP Console" service provider for Laravel https://github.com/barbushin/php-console-laravel
还有用于 Laravel 的 Google Chrome 扩展“PHP 控制台”服务提供商https://github.com/barbushin/php-console-laravel
回答by Renato Cassino
You can use the dephpugger. Is a debugger to run in terminal.
您可以使用 dephpugger。是在终端中运行的调试器。
Is really simple to use and works like byebug in ruby. https://github.com/tacnoman/dephpugger
使用起来非常简单,就像 ruby 中的 byebug 一样。 https://github.com/tacnoman/dephpugger