From 4fd2edbeb42b842d0c7cdb00363c7b09aa89b906 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Fri, 22 Nov 2013 12:38:40 +0000 Subject: [PATCH] initializing tut --- tutorials/initializing.md | 82 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tutorials/initializing.md diff --git a/tutorials/initializing.md b/tutorials/initializing.md new file mode 100644 index 0000000000..de01bb23fa --- /dev/null +++ b/tutorials/initializing.md @@ -0,0 +1,82 @@ +phpdbginit +========== +*Setting up your debugging session automatically* + +By default, phpdbg looks for *.phpdbginit* in the current working directory, this location can be overrideen on the command line: + +``` +phpdbg -imy.phpdbginit +``` + +An init file should contain one command per line, any phpdbg command is supported during init. + +In addition, *.phpdbginit* can contain embedded code, allowing, for example + + - the setup of auto completion + - the registration of functions + - the acquisition and pre-compilation of code + - bootstrapping a web application + +It is common for C projects (PHP included) to include an init file for the GDB debugger; this would be a clever practice to adopt +for those distributing PHP library code. + +The default .phpdbginit +======================= + +We distribute the following init file by default, it should be copied to any directory you commonly execute in: + +``` +########################################################## +# .phpdbginit +# +# Lines starting with # are ignored +# Code must start and end with <: and :> respectively +########################################################## +# Place initialization commands one per line +########################################################## +# exec sapi/phpdbg/test.php + +########################################################## +# Embedding code in .phpdbginit +########################################################## +<: +/* + If readline is loaded, you might want to setup completion: +*/ +if (function_exists('readline_completion_function')) { + readline_completion_function(function(){ + return array_merge( + get_defined_functions()['user'], + array_keys(get_defined_constants()) + ); + }); +} +:> +########################################################## +# Now carry on initializing phpdbg ... +########################################################## +# R my_debugging_function + +########################################################## +# PHP has many functions that might be useful +# ... you choose ... +########################################################## +# R touch +# R unlink +# R scandir +# R glob + +########################################################## +# Remember: *you have access to the shell* +########################################################## +# The output of registered function calls is not, +# by default, very pretty (unless you implement +# and register a new implementation for phpdbg) +# The output of shell commands will usually be more +# readable on the console +########################################################## +# TLDR; if you have a good shell, use it ... +########################################################## +``` + + -- 2.40.0