DevTools Timeline Viewer lets you share and view DevTools Timeline traces online, in the browser. Handy if you want to share a Timeline trace with someone to help you debugging.
DevTools Timeline Viewer →
DevTools Timeline Viewer Example →
A rather geeky/technical weblog, est. 2001, by Bramus
DevTools Timeline Viewer lets you share and view DevTools Timeline traces online, in the browser. Handy if you want to share a Timeline trace with someone to help you debugging.
DevTools Timeline Viewer →
DevTools Timeline Viewer Example →
Available in the nightly build of Node.js (not the release version, yet).
Here’s a video of it in action (skip forward to 42:51):
Paul Irish has got you covered on how to set this up:
Debugging Node.js Nightlies with Chrome DevTools →
Control, monitor, and instrument your React and React Native apps from the comfort of your TTY.
TraceGL transforms your JavaScript, injecting monitoring code that produces a log of everything that happens. This log is streamed from the target – via the traceGL node.js process – to the UI for visualisation. The UI tries to display the resulting huge amount of information fast, and uses webGL to render everything.
In the video above you can see @rem take this for a spin.
PHP 5.6.0, currently in alpha, will hit us any time later this year. Time to take a look and see what’s new. Here’s a selection of features that will affect the way you and I code.
__debugInfo()
magic function (rfc)This new magic function allows you to instruct PHP what it should output when using var_dump()
. Take this simple class for example:
class File {
private $fp;
public function __debugInfo() {
return $this->fp ? stream_get_meta_data($fp) : [];
}
public function open($filename, $mode = 'r'){
$this->fp = fopen($filename, $mode);
}
}
In PHP < 5.6 you’d get back a simple dump of all the datamembers the class holds. This is not always helpful, as seen in the example below:
$f = new File();
$f->open('http://php.net');
var_dump($f);
object(File)#1 (1) {
["fp":"File":private]=>
resource(5) of type (stream)
}
With PHP 5.6 the __debugInfo()
function will kick in, and send back that result to var_dump()
:
$f = new File();
$f->open('http://php.net');
var_dump($f);
object(File)#1 {
["wrapper_type"]=>
string(4) "http"
["stream_type"]=>
string(10) "tcp_socket"
…
}
Note that you can safely use this function PHP < 5.6, as older versions of PHP will just ignore it.
~
So we all know +
, -
, *
, /
, .
, etc. right? Well, there’s a new kid in town: **
, which is PHP’s exponential operator:
echo 2 ** 4; // 16
Beware: it’s right associative, meaning the expression on the right will be interpreted first when using multiple operators:
echo 2 ** 3 ** 2; // 512 (not 64)
~
Arrays (and Traversables) can now be unpacked using the ...
operator (splat operator), which is prefixed to the variable. This will allow you to remove all those call_user_func_array()
calls (if you have any).
Pre PHP 5.6:
call_user_func_array([$db, 'query'], array_merge(array($query), $params));
With PHP 5.6, using the splat operator:
$db->query($query, ...$params);
Here’s an other simple example:
<?php
function add($a, $b, $c) {
return $a + $b + $c;
}
$operators = [2, 3];
echo add(1, ...$operators);
~
Pre PHP 5.6 there’s no way to syntactically spot a variadic function (= a function that has a variable number of arguments). Above that you had to do some funky stuff using array_slice()
in order to get the remaining arguments:
class MySQL implements DB {
protected $pdo;
public function query($query) {
$stmt = $this->pdo->prepare($query);
$stmt->execute(array_slice(func_get_args(), 1));
return $stmt;
}
// ...
}
$userData = $db->query('SELECT * FROM users WHERE id = ?', $userID)->fetch();
PHP 5.6 sports a syntax for variadic functions: pass in an extra parameter and prepend it with aforementioned splat operator (...
). Next to being able to spot a variadic by just looking at the syntax, you’ll also able to quickly access the remaining function parameters, as the variable will already be unpacked:
class MySQL implements DB {
public function query($query, ...$params) {
$stmt = $this->pdo->prepare($query);
$stmt->execute($params);
return $stmt;
}
// ...
}
$userData = $db->query('SELECT * FROM users WHERE id = ?', $userID)->fetch();
~
The problem with constants in PHP pre PHP 5.6 is that they’re – well … – constant. They must be a fixed value, not a computed one. In PHP 5.6 this will change.
Constants as defined below are now accepted:
const A = 1 + 1;
const B = 2 ** A;
const HELLO = "HELLO";
const HELLO_WORLD = HELLO . " WORLD";
~
phpdbg
is an interactive PHP debugger. It’s a single executable which you run at the terminal. Once booted you instruct PHP where to break (be it on a line number, at a function call, etc.). Take this sample.php
for example:
<?php
$a = 1 + 2;
echo $a;
Debug it using phpdbg
as follows:
[email protected]:~$ phpdbg -e sample.php
[Welcome to phpdbg, the interactive PHP debugger, v0.3.0]
To get help using phpdbg type "help" and press enter
[Please report bugs to ]
phpdbg> compile
[Attempting compilation of /home/yoya/sample.php]
[Success]
phpdbg> print exec
[Context /home/yoya/sample.php]
L0-0 {main}() /home/yoya/sample.php
L2 0x7f6c901d1c60 ZEND_ADD C0 C1 @0
L2 0x7f6c901d1c90 ZEND_ASSIGN $a @0 @1
L3 0x7f6c901d1cc0 ZEND_ECHO $a <unused> <unused>
phpdbg> break line 3
[Breakpoint #0 added at line 3]
phpdbg> run
3phpdbg>
Alternatively you can break from within your PHP code using phpdbg_break()
. Also note that the compile
step is not mandatory.
Once a breakpoint was reached you can inspect the current environment, agina using commands such as list
, print
, info
, etc. Other familiar debug commands such as step
, next
, leave
, etc. are also available.
phpdbg
also allows you to remotely debug. Mocking a server is also possible.
The next version of PHPStorm will use phpdbg
as the default debugger. Also pretty sure someone on the interwebs will write a nice standalone GUI for this if you’re not that into CLI mode nor PHPStorm.
~
With PHP 5.6 the use
operator will be extended to also import functions and constants using use function
and use const
:
<?php
namespace Name\Space {
const FOO = 42;
function f() { echo __FUNCTION__ . PHP_EOL; }
}
namespace {
use const Name\Space\FOO;
use function Name\Space\f;
echo FOO . PHP_EOL; // 42
f(); // Name\Space\f
}
Note that you still won’t be able to import an entire namespace using the use
operator. You’ll still have to reside to aliasing the namespace (and using that alias further down):
<?php
namespace foo\bar {
function baz() {
return 'foo.bar.baz';
}
}
namespace {
use foo\bar as b;
var_dump(b\baz());
}
~
Next to these new syntactic features, a few other things – such as SSL/TLS improvements, Large file uploads, and a reusable php://input
– will also land in PHP 5.6.
I don’t run ads on my blog nor do I do this for profit. A donation however would always put a smile on my face though. Thanks!
Level up on the Javascript console in the Chrome DevTools. Look at XHR requests, learn console helper functions to monitor events or explore objects better. Paul Irish from the Chrome team gives you a rundown.
We all know console.x
, but there’s some more stuff to do in the console … sure that $0
shorthand will be used quite often over here!
jsconsole.com is a simple JavaScript command line tool. However, it also provides the ability to bridge across to other browser windows to remotely control and debug that window – be it in another browser or another device altogether.
Remote debugging is really simple:
:listen
command at jsconsole.com to get a listener id returnedhttp://jsconsole.com/remote.js?listenerid
in the page you want to debugOnce included jsconsole.com will catch all console.log
s from the page. Above that it will execute any command entered at jsconsole.com in the scope of the page that has remote.js
included.
Here’s a little demo video:
Do your mobile development straight from your desktop, and pair it with Opera Dragonfly for advanced debugging.
This version of Shadow focuses primarily on the following:
- Local Host URL Support
- Adobe Edge Integration
- Improved workflows for sticky caches, HTTP Authentication Support and URL Monitoring
Shadow – Labs Release 2 now available →
Adobe Shadow on Adobe Labs →