php有debugger,Php Debugger可以在终端中运行,方便您调试代码

68747470733a2f2f7472617669732d63692e6f72672f7461636e6f6d616e2f646570687075676765722e7376673f6272616e63683d6d617374657268747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f7461636e6f6d616e2f646570687075672f6261646765732f6770612e737667687474703a2f2f686974732e6477796c2e696f2f7461636e6f6d616e2f646570687075676765722e73766768747470733a2f2f636f6465636f762e696f2f67682f7461636e6f6d616e2f646570687075676765722f6272616e63682f6d61737465722f67726170682f62616467652e73766768747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7461636e6f6d616e2f646570687075676765722e73766768747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f7461636e6f6d616e2f646570687075676765722e73766768747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7461636e6f6d616e2f64657068707567676572

8fb0601eff479912f91bc22628b5eb72.png

What is Dephpugger?

Dephpugger (read depugger) is an open source lib to make a debug in php direct in terminal, without necessary configure an IDE. The dephpugger run in Php Built in Server using another command. You can use for:

Web applications

Lumen in example

dephpugger-web.gif Image 1.0 - Screenrecord for debug web

Cli Scripts

316efb1ee82c1c687ee013ca23c188f0.gif Image 1.1 - Screenrecord for debug cli scripts

Another example

a0bc1ebac63372898ea9c2d5ac9fd6f4.gif

Install

To install you must run this code (using the composer).

$ composer require tacnoman/dephpugger

Install globally

In Linux or Mac Os X

Run this command:

$ composer global require tacnoman/dephpugger

And add in your ~/.bash_profile.

export PATH=$PATH:$HOME/.config/composer/vendor/bin

Now, run source ~/.bash_profile and you can run the commands using only $ dephpugger.

In Windows

Sorry for this :/ I don't have Windos SO to run the Dephpugger, but I'm waiting your Pull Request to solve this ;D

But you can use Docker

Using phar file

$ wget https://raw.githubusercontent.com/tacnoman/dephpugger/master/dephpugger.phar -O dephpugger

$ chmod +x ./dephpugger

$ mv ./dephpugger /usr/local/bin/dephpugger

Or installing via curl

$ curl https://raw.githubusercontent.com/tacnoman/dephpugger/master/installer.sh | bash

Install XDebug

To install XDebug in Linux you must run:

$ sudo apt-get install php-7.2-cli php-dev php-pear

$ sudo pecl install xdebug

Find the last line, similar to: You should add "zend_extension=/usr/lib/php/20170718/xdebug.so" to php.ini and copy to your php.ini file. To get the php.ini file, you can run:

$ php --info | grep php.ini

Configuration File (php.ini) Path => /etc/php/7.2/cli

Loaded Configuration File => /etc/php/7.2/cli/php.ini

Copy the zend_extension=/usr/lib/php/20170718/xdebug.so to last line in /etc/php/7.2/cli/php.ini.

Docker

$ docker run --rm -p 8888:8888 tacnoman/dephpugger:latest server

Dependencies

PHP 7.0 or more (not tested in older versions)

Xdebug activate

A Plugin for your browser (If you want to debug a web application)

Plugins for

You can run this commands to check your dependencies:

$ vendor/bin/dephpugger requirements

$ vendor/bin/dephpugger info # To get all values setted in xDebug

# Or in global

$ dephpugger requirements

$ dephpugger info

Usage

To usage you must (after installation) run two binaries in vendor/bin folder.

$ php vendor/bin/dephpugger debugger # Debugger waiting debug

$ php vendor/bin/dephpugger server # Server running in port 8888

# Or in global

$ dephpugger debugger

$ dephpugger server

You must run in two different tabs (in next version you'll can run in an uniq tab). After run theese commands, you need to put the follow line in your code:

# ...

xdebug_break(); # This code is a breakpoint like ipdb in Python and Byebug in Ruby

# ....

Now, you can open in your browser the page (localhost:8888/[yourPage.php]). When you request this page your terminal will start in breakpoint (like the image 1.0).

To debugger a php script, you could run:

$ php vendor/bin/dephpugger cli myJob.php

# Or in global

$ dephpugger cli myJob.php

Comands after run

When you stop in a breakpoint you can make theese commands:

Command

Alias

Explanation

next

n

To run a step over in code

step

s

To run a step into in code

set :

Change verboseMode or lineOffset in runtime

continue

c

To continue script until found another breakpoint or finish the code

list

l

Show next lines in script

list-previous

lp

Show previous lines in script

help

h

Show help instructions

$variable

Get a value from a variable

$variable = 33

Set a variable

my_function()

Call a function

dbgp()

To run a command in dbgp

quit

q

Exit the debugger

Configuration (is simple)

The Dephpugger project has default options like a port, host, socket port, etc. You can change this values adding a file .dephpugger.yml in root directory project. You can create in your .dephpugger.yml file the configurations. Like this:

---

debugger:

host: mysocket.dev# default: 0.0.0.0

port: 9002 # default: 9005

lineOffset: 10 # default: 6

verboseMode: false# default: false

historyFile: ~/.dephpugger_history# default: .dephpugger_history

server:

host: myproject.dev# default: 0.0.0.0

port: 8080 # default: 8888

path: ./public/# default: null

file: index.php# default: null

Theese values will replace the default configuration.

Full documentation

To see the full documentation click here.

How to use with phpunit, behat, codeception and others

The documentation to use, click here.

Run tests

$ composer test

$ composer lint

Bugs?

Send me an email or open an issue:

Renato Cassino - Tacnoman -

Articles and Videos

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值