Magento patch failing to install - php

When downloading and running the Magento PHP 5.4 support patch (Magento-CE-v1.7.0.0-1.7.0.2) from http://www.magentocommerce.com/download, running the script using sh PATCH_SUPEE-2629_EE_1.12.0.0_v1.sh we receive this error:
$ sh PATCH_SUPEE-2629_EE_1.12.0.0_v1.sh
: command not found_1.12.0.0_v1.sh: line 7:
'ATCH_SUPEE-2629_EE_1.12.0.0_v1.sh: line 9: syntax error near unexpected token `{
'ATCH_SUPEE-2629_EE_1.12.0.0_v1.sh: line 9: `_check_installed_tools() {
Strangely, line 7 of the script is blank (here's the head of the file):
#!/bin/bash
# Patch apllying tool template
# v0.1.2
# (c) Copyright 2013. Magento Inc.
#
# DO NOT CHANGE ANY LINE IN THIS FILE.
# 1. Check required system tools
_check_installed_tools() {
local missed=""
We tried the download in Windows and Mac, in Firefox and Chrome to rule out any encoding problems caused by the download process. The patch seems to be very new - Added Jan 17, 2014
We're running Magento Community Edition 1.7.0.2
Edit
We've tried running the .sh file with bash as well but receive the same response.
Interestingly when the click "download", Magento shows the .sh source in the browser so we tried various combinations of view-source then save; copying the text from the browser window and saving it to a text file. None of these solved the problem although one changed the error message to:
$ sh PATCH_SUPEE-2629_EE_1.12.0.0_v1.sh
Checking if patch can be applied/reverted successfully...
/usr/bin/patch: **** malformed patch at line 238:
ERROR: Patch can't be applied/reverted successfully.
Line 238 is the blank comment line here:
+/**
+ * Abstract helper class for {#link Zend_Pdf_FileParser} that provides the
+ * data source for parsing.
+ *
+ * Concrete subclasses allow for parsing of in-memory, filesystem, and other
+ * sources through a common API. These subclasses also take care of error
+ * handling and other mundane tasks.
We also tried the VI step mentioned here - :set ff unix
http://www.magentocommerce.com/boards/viewthread/864518
The error then changed to:
$ sh PATCH_SUPEE-2629_EE_1.12.0.0_v1.sh
Checking if patch can be applied/reverted successfully...
ERROR: Patch can't be applied/reverted successfully.
patching file app/code/core/Mage/Catalog/Model/Product.php
Hunk #1 FAILED at 1936.
1 out of 1 hunk FAILED -- saving rejects to file app/code/core/Mage/Catalog/Model/Product.php.rej
patching file app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
Hunk #1 FAILED at 43.
1 out of 1 hunk FAILED -- saving rejects to file app/code/core/Mage/Core/Controller/Varien/Router/Standard.php.rej
patching file app/code/core/Mage/Install/etc/config.xml
patching file app/code/core/Zend/Pdf/FileParserDataSource.php

It turns out that this error is given when the patch file (not the file being patched) has line endings which do not match the system on which it is being run.
eg: You will see this error when:
You are running on Linux
Your patch file has Windows line endings
I changed the patch file to have Unix line endings using Sublime:
View > Line Endings > Unix
See also Error patching Magento 1.7.1 Hunk #1 Failed at

Related

PHP exec : dirvish default error (23) -- partial transfer

I have web services that are used for backups, but since the move to PHP7 (?) The backup no longer works.
All web services links work.
I isolated the code that is a problem in PHP 7 but it can come from something else!
<?php
//$outputShell=shell_exec('sudo cat /etc/passwd');
exec('sudo /usr/sbin/dirvish --vault L106',$outputShell, $codeErreur);
//exec('sudo cat /etc/passwd',$outputShell, $codeErreur);
//
if ($codeErreur == 0){
var_dump ("ok",$outputShell,$codeErreur);
}
else{
var_dump ("nook",$outputShell,$codeErreur);
}
?>
When I execute this code directly via a browser I have this error:
dirvish error: branch /san/pcdsi/L106:default image 20190221154124
failed dirvish L106:default error (23) -- partial transfer expr:
syntax error expr: non-integer argument dirvish error: branch
/san/pcdsi/L106:default image 20190221154136 failed
and log dirvish
rsync_error: * Execution cycle 0 rsync: change_dir
"/mnt/pc-backup/L106/Users/" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous
errors) (code 23) at main.c(1668) [Receiver=3.1.2] rsync: [Receiver]
write error: Broken pipe (32) Execution cycle 1 * rsync:
change_dir "/mnt/pc-backup/L106/Users/" failed: No such file or
directory (2) rsync error: some files/attrs were not transferred (see
previous errors) (code 23) at main.c(1668) [Receiver=3.1.2] rsync:
[Receiver] write error: Broken pipe (32)
If I run the / usr / sbin / dirvish --vault L106 command in root, the backup is done without any problem !!
In addition the part in a comment that I tested via cat / etc / passwd works!
Of course, I checked the rights sudo and the script being launched via a browser www-data is sudo without password ... no problem on this side there
On my old PHP 5 server, this PHP code works!
Do you have an idea? I hold?
- system problem?
- PHP problem?
- dirvish problem on PHP 7 platform?
In short, the exec command ('sudo / usr / sbin / dirvish --vault L106', $ outputShell, $ errorCode); works in PHP 5 and not in PHP 7!!

Using PHPUnit in PhpStorm using Docker

I have a very specific configuration that I have to hold until I can start moving feature from my old PHP 5 application to somewhere else.
I'm trying to tie my testing environment with PhpStorm but I cant figure it out. Since I'm not using Composer, I have to specify phpunit.phar path (which is /usr/local/bin/phpunit - a symlink to /usr/local/bin/phpunit.phar). I keep having this error.
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Cannot create phar '/usr/local/bin/phpunit', file extension (or combination) not recognised or the directory does not exist' in /opt/.phpstorm_helpers/phpunit.php:181
Stack trace:
#0 /opt/.phpstorm_helpers/phpunit.php(181): Phar->__construct('/usr/local/bin/...')
#1 /opt/.phpstorm_helpers/phpunit.php(250): IDE_PHPUnit_Loader::init()
#2 {main}
thrown in /opt/.phpstorm_helpers/phpunit.php on line 181
The setup on my Docker is
PHP 5.5.9 with PHPUnit 4.8.9
My remote Docker PHP interpreter works in PhpStorm, and my PHPUnit works when I run test in bash (using docker exec phpunit) - so it seems that the pieces are working, mostly the glue doesn't work.
Here are my settings
I just ran into this problem with composer and the issue is you need to set up a PHPUnit interpreter in PHPStorm with the autoload.php file.
Open Settings > Languages & Frameworks > PHP > Test Frameworks
Click the Plus + icon to add a Remote Interpreter
Select the CLI interpreter previously defined and use existing path mappings
Select Use Composer Autoloader
Path to script should be /path/to/vendor/autoload.php
Check off Default configuration file and set it to /path/to/phpunit.xml
I also needed to have the following section in my docker-compose.yml:
services:
my-api:
# Other contents omitted
environment:
- PHP_IDE_CONFIG=serverName=my-api.company.com
Where my-api.company.com is the server definition name from Settings > Languages & Frameworks > PHP > Servers

Unable to capture changes to log file via nagios check_logwarn plugin command invoked via PHP exec() triggered via Jenkins

I am using nagios check_logwarn to capture changes to log files.
In order to test my setup, I have been manually adding the following log line to the concerned log file -
[Mon Mar 20 14:24:31 2017] [hphp] [12082:7f238d3ff700:32:000001] []
\nFatal error: entire web request took longer than 10 seconds and timed out in /var/cake_1.2.0.6311-beta
app/webroot/openx/www/delivery/postGetAd.php on line 483
The above should get caught by the following nagios command, because it contains the keyword "Fatal"
/usr/local/nagios/libexec/check_logwarn -d /tmp/logwarn_hiphop_error -p /mnt/log/hiphop/error_`(date +'%Y%m%d')`.log "^.*Fatal*"
Output (as expected) -
Log errors: \nFatal error: entire web request took longer than 10 seconds and timed out in /var/cake_1.2.
0.6311-beta
\nFatal error: entire web request took longer than 10 seconds and timed out in /var/cake_1.2.0.6311-beta
Running this command directly works (case 1), but it seems invoking the same via a PHP exec which is triggered via a Jenkins project is not catching the same (case 2).
Following is the PHP code of case 2 -
$errorLogCommand = '/usr/local/nagios/libexec/check_logwarn -d /tmp/logwarn_hiphop_error -p /mnt/log/hiphop/error_'.$date.'.log "^.*Fatal*"';
$output = exec($errorLogCommand);
file_put_contents('/var/cake_1.2.0.6311-beta/deployment/deployment.log', "\n ".date("Y-m-d H:i:s")." Checked error key words in error_".$date.".log. command -> ".$errorLogCommand, FILE_APPEND);
if($output!="OK: No log errors found")
{
file_put_contents('/var/cake_1.2.0.6311-beta/deployment/deployment.log', "\n ".date("Y-m-d H:i:s")." - Hiphop errors -> ".$output, FILE_APPEND);
$failure=true;
break;
}
else
{
file_put_contents('/var/cake_1.2.0.6311-beta/deployment/deployment.log', "\n ".date("Y-m-d H:i:s")." - No Error found -> ".$output, FILE_APPEND);
}
Following is the output -
2017-03-20 14:16:45 Checked error key words in error_20170320.log. command -> /usr/local/nagios/libexec/
check_logwarn -d /tmp/logwarn_hiphop_error -p /mnt/log/hiphop/error_20170320.log "Fatal"
2017-03-20 14:16:45 - No Error found -> OK: No log errors found
Note that with the same nagios command (/usr/local/nagios/libexec/check_logwarn) as in case 1, log error is not detected in this case, unexpectedly.
Following are my observations of the contents of the internal tracker file which nagios generates - /tmp/logwarn_hiphop_error/mnt_log_hiphop_error_20170320.log -
When error is detected in case 1, following are the changes in the file -
Before running command
# logwarn 1.0.10 state for "/mnt/log/hiphop/error_20170320.log"
INODENUM="1208110246"
LINENUM="110"
POSITION="111627"
MATCHING="true"
After running command
# logwarn 1.0.10 state for "/mnt/log/hiphop/error_20170320.log"
INODENUM="1208110246"
LINENUM="116"
POSITION="112087"
MATCHING="false"
Also, following are the changes to the same file in case 2 -
Before running php file
# logwarn 1.0.10 state for "/mnt/log/hiphop/error_20170320.log"
INODENUM="1208110246"
LINENUM="102"
POSITION="109329"
MATCHING="true"
After
# logwarn 1.0.10 state for "/mnt/log/hiphop/error_20170320.log"
INODENUM="1208110246"
LINENUM="110"
POSITION="111627"
MATCHING="true"
I am not sure why the MATCHING parameter is true in the case 2, whereas in case 1 it is false. In fact, the error matching happened in case 1.
Update
I tried wrapping the command in an escapeshellcmd, to ensure that the regex is not being stripped out -
$output = exec(escapeshellcmd($errorLogCommand));
but still no change in output.
Update 2
Found that I had line breaks in the log line I was manually adding. Removing those fixed it consistently for the case of running the PHP file from command line. However, the problem is still reproducible consistently for the case 2, where I am triggering the project via Jenkins and this file gets called in one of the hooks of AWS code deploy.
Well, it seems this is not going to get solved so easily. The problem got fixed for manual invocation of the PHP file, but on invocation via Jenkins, I am still getting the same problem consistently.
The logwarn documentation mentions support for a negative checking expression.
Please try pre-pending an exclamation mark (!) before the pattern string to exclude rather than include these matches

Windows 8.1 why does RabbitMQ dont work?

Hi i can't run RabbitMQ service or broker
--old non important removed content--
please help me, how can i fix it ? i have instaled newest erlang x64 version
#UPDATE
here after changing the RABBITMQ_BASE i still got this error
how it looks like now:
=CRASH REPORT==== 27-Aug-2014::12:30:52 ===
crasher:
initial call: application_master:init/4
pid: <0.70.0>
registered_name: []
exception exit: {bad_return,
{{rabbit,start,[normal,[]]},
{'EXIT',
{badarg,
[{io_lib,format,
["~-15s: ~s~n",
["home dir",
[67,58,92,85,115,101,114,115,92,82,97,
102,97,322]]],
[{file,"io_lib.erl"},{line,154}]},
{rabbit_misc,format,2,[]},
{rabbit,'-log_banner/0-lc$^1/1-1-',2,[]},
{rabbit,'-log_banner/0-lc$^1/1-1-',2,[]},
{rabbit,log_banner,0,[]},
{rabbit,start,2,[]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},
{line,272}]}]}}}}
in function application_master:init/4 (application_master.erl, line 133)
ancestors: [<0.69.0>]
messages: [{'EXIT',<0.71.0>,normal}]
links: [<0.69.0>,<0.7.0>]
dictionary: []
trap_exit: true
status: running
heap_size: 1598
stack_size: 27
reductions: 222
neighbours:
and from console
Starting broker...
BOOT FAILED
===========
Error description:
{could_not_start,rabbit,badarg}
Log files (may contain more information):
d:/Program Files (x86)/RabbitMQ Server/rabbitmq_server-3.3.5/base/log/rabbit#
VARDIUS.log
d:/Program Files (x86)/RabbitMQ Server/rabbitmq_server-3.3.5/base/log/rabbit#
VARDIUS-sasl.log
{"init terminating in do_boot",{rabbit,failure_during_boot,{could_not_start,rabb
it,badarg}}}
Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
d:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.3.5\sbin>
RabbitMQ is trying to print out the following message:
RabbitMQ 3.3.5. Copyright (C) 2007-2014 GoPivotal, Inc.
## ## Licensed under the MPL. See http://www.rabbitmq.com/
## ##
########## Logs: C:/Users/Rafał/AppData/Roaming/RabbitMQ/log/rabbit#VARDIUS.log
###### ## C:/Users/Rafał/AppData/Roaming/RabbitMQ/log/rabbit#VARDIUS-sasl.log
##########
Starting broker...ok
But it fails to do so, because on one hand the filename is given as a Unicode "string", i.e. a list of code points (note the 322 in the middle, which stands for ł), but on the other hand RabbitMQ is trying to print this as a non-Unicode string (using the ~s directive instead of ~ts).
I'd suggest you report this as a bug to the RabbitMQ developers. Meanwhile, you could try running it from a directory whose path doesn't contain non-ASCII characters.
I had the exact same problem. My workaround solution was to insert an additional batch line in rabbitmq-server.bat or rabbitmq-service.bat files:
SET HOMEPATH=\SOME_PATH_WITHOUT_NON_ASCII_CHARACTERS
%HOMEDRIVE%%HOMEPATH% is used as a path where the .erlang.cookie file is stored. I've also set RABBITMQ_BASE to some non-ascii path too, like you did.
This solution was inspired by this SO Answer.

xdebug configuring error: Function registration failed - duplicate name

I am trying to use xdebug to debug a really large php system. I have added the following lines to the php.ini on a Linux system:
[XDebug]
zend_extension = "/usr/lib/php4/lib/php/extensions/no-debug-non-zts-20020429/xdebug.so"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1 ;
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "/tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.trace_output_dir = "/tmp"
However, after restarting apache I am unable to reload a php-generated page in the web-browser. The apache error-log contains the following output:
PHP Warning: Function registration failed - duplicate name - xdebug_get_stack_depth in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_get_function_stack in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_print_function_stack in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_get_declared_vars in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_call_class in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_call_function in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_call_file in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_call_line in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_var_dump in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_debug_zval in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_debug_zval_stdout in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_enable in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_disable in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_is_enabled in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_break in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_start_trace in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_stop_trace in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_get_tracefile_name in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_get_profiler_filename in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_dump_aggr_profiling_data in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_clear_aggr_profiling_data in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_time_index in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_start_code_coverage in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_stop_code_coverage in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_get_code_coverage in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_get_function_count in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_dump_superglobals in Unknown on line 0
PHP Warning: xdebug: Unable to register functions, unable to load in Unknown on line 0
[Wed Jun 11 17:26:56 2014] [notice] Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8k PHP/4.4.9-pl0-gentoo configured -- resuming normal operations
[Wed Jun 11 17:27:01 2014] [notice] child pid 21745 exit signal Segmentation fault (11)
[Wed Jun 11 17:27:02 2014] [notice] child pid 21752 exit signal Segmentation fault (11)
How to fix this problem so I can use xdebug to debug the php system?
Additional information:
There is also a xdebug.ini file - so I removed all xdebug related text from php.ini.
I have added the following two lines to the php code I want to debug:
xdebug_enable();
xdebug_start_trace();
Configuring Xdebug for PHP development/Linux
XDEBUG EXTENSION FOR PHP | DOCUMENTATION
Installation
There are several ways to download and install Xdebug to your Linux box, you can do it from your software center, terminal or manual download.
Method 1: From a Linux repository
A Tip!
This is the recommended method because you will get updates and
security patches automatically.
Option 1: Terminal
Open your terminal and type
sudo apt-get install php5-xdebug
Wait until the installation process finish
Option 2: Software center
Open the software center that comes with your distribution
Type in the search box "Eclipse IDE"
Select "Eclipse IDE" in the search result list
Click on the "install" button
Wait until installation processes finish
Method 2: From a downloaded copy
Visit this page here and download the most recent version available
Do a double click on the downloaded file, your package manager should do the rest of the work automatically http://packages.debian.org/sid/php5-xdebug
Configuring Xdebug
Open your terminal and type
sudo gedit /etc/php5/mods-available/xdebug.ini
if the file is empty try this location
sudo gedit /etc/php5/conf.d/xdebug.ini
hat command should open the text editor with the Xdebug configuration file
At the end of the file content append the following text
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
Save changes and close the editor
In you terminal type
sudo service apache2 restart
Note: You can set a different port number if you need to.
Configuring Eclipse IDE
Open Eclipse IDE
On Eclipse go to: "Toolbar → Window → Preferences → PHP → Debug"
Find the option: "PHP Debugger" and set it to "Xdebug"
On Eclipse go to: "Toolbar → Window → Preferences → PHP → Debug → Installed Debugger"
In the list make sure the port the "Xdebug" option is set to the value "9000"
Save changes
Note: You can set a different port number if you need to.
When you debug a PHP project Xdebug stops the code execution of the current page and Eclipse IDE by default pops out a perspective with 2 views containing the internal Eclipse IDE web browser and the a view with the current HTML output, if you don't like the internal web browser you can use any other external web browser you got installed in your computer, such as gogle chrome, chromium, firefox, etc... don't even try IE, just kidding :p .
To set up a different web browser follow these steps if you are OK with the Eclipse internal browser skip this part:
On Eclipse go to: "Toolbar,Window,Preferences,General,Web Browser"
Make sure the option "Use external browser" is selected
If your preferred browser is on the list, select it and save changes and skip the rest of this part
If your preferred browser is not on the list press the button "New"
Set a name for your new browser i.e. "chrome"
Set the location of your new browser i.e. "/usr/bin/google-chrome"
If you don't know the location of the browser open a terminal and use the command "whereis browsername" to display the browser location. Note: Replace browsername with the name of your preferred browser i.e. "whereis google-chrome" copy one of the locations if there is more than one
Save all changes
Testing Xdebug and Eclipse IDE
To test our brand new debugging tool we need to create an Eclipse PHP project, set the debug configuration for our project and write some few lines of PHP code. This example assumes 3 things:
You understand the Eclipse IDE concepts of "workspace" and "projects", if not, pleas read this article Configuring Eclipse IDE for PHP development/Linux#Understanding the folder structure
You already have a working web server if not, pleas read this article. Configuring a LAMPP server for PHP development/Linux desktop
Your Eclipse workspace is located at the server's web root folder.
Configuring the workspace
If your current workspace is located at your server's web root skip this part
Open Eclipse IDE
On Eclipse go to: "Toolbar → File → Switch workspace → Other"
Press the button "browse" and browse the location of your server's web root folder, i.e. "/home/youruser/lamp/public_html/"
Press "OK" and wait until Eclipse IDE restarts and load the new workspace
Configuring the test project
On Eclipse go to: "Toolbar → File → New → Other → PHP → PHP Project"
Set the project name to "xdebug-test" or anything you like
Press "Ok" to continue
After this Eclipse IDE will automatically create a project folder like this "/home/youruser/lamp/public_html/xdebug-test/", also you should be able to visualize the new project at the Eclipse IDE Project Explorer view or Navigation view
On Eclipse go to: "Toolbar → File → New → Other → PHP → PHP File"
Set the file name to "index.php"
Press "Ok" to continue
After this Eclipse IDE will automatically create a PHP file like this "/home/youruser/lamp/public_html/xdebug-test/index.php", also you should be able to visualize the new file at the Eclipse IDE Project Explorer view or Navigation view
Find the new "index.php" file at the Eclipse IDE project explorer and open it doing double click on it
Place the following content to that file:
<?php
$X = 5;
$X = 8;
$Y = 2;
$Z = $X + $Y;
$Z = $Z + 1;
echo "Z value is: " . $Z;
?>
Save changes
open your web browser and navigate to
"http://example.com/xdebug-test/index.php"
It should display a web and output like this
Z value is: 11
Configuring the test project debug information
On Eclipse go to: "Toolbar → Run → Debug configuration..."
On the left list find "PHP Web Application" and do a double click on it to create a new configuration element
Select the new configuration element to display it content
Set the name to "xdebug-test" or anything you like
Make sure the option "Server debugger" is set to "Xdebug"
Make sure the option "Break at first Line" is not checked
In the option "File" press the button "Browse", find your project "xdebug-test" and expand it content, then find and select the file "index.php"
Make sure that option URL looks something like this "http://example.com/xdebug-test/index.php"
Press "Apply" and "Close" to save changes and continue
Debugging the test project
As you can see our "index.php" file have several lines of code, with the debugger we can study how those lines of code that are being executed one by one, but to stop the execution we need to set something called "Breakpoint", a Breakpoint is a "mark" in our lines of code that indicate to the debugger to stop the execution and poll the var values. To set a Breakpoint on our code and test the debugger follow this simple steps.
Open the "index.php" of our test project
Locate the line of code "$X
= 8;" and do a click on it to place the blinking cursor there
On Eclipse go to: "Toolbar → Run → Toggle Breakpoint", you can also used
the hotkey "shift+ctrl+B" or simply do a double click on the line
number of the line of code at the very left side of your editor to
toggle a Breakpoint
When a Breakpoint is set you should see it
represented as a little circle next to the line number at the very
left side of your editor
Now is time to execute our project to see how the debugger help us to debug the code.
On Eclipse go to: "Toolbar → Run → Debug", you can also used the hotkey "F11" or simply do a click in the "little bug icon" located at the second toolbar from the top
Automatically Eclipse will open the configured web browser, and also change to the "Debug perspective", the debug perspective contains a set of pre-configured views useful to do debugging tasks, among them we got:
Debug view: It display buttons to control the current running debug session and also this view contains the current call stack
Breakpoint view: display all the your set breakpoints on any project file
Variables view: Is is basically a "var dump" of all the PHP variables of your actual session, it view let you easily navigate throw any variable and child members of those variables.
Expressions view: there you can set custom expressions i.e. "$X+$Y+$Z" and see the outcome of each expression without changing the code at all.
Internal browser view and output view: optional if you not configured an external browser Eclipse IDE will display this view with the current page and the current page HTML output
At this point our web page should look stopped and most likely the browser will show a blank page "waiting" to load the rest of it
Note that the current breakpoint have a "little arrow" over the circle and the line of code if highlighted, this indicated what is the next line of code to be executed, also know as the "current step"
If you take a look at the "variables view" the current value of "$X" should be "5"
Go to the "Debug view" and press the button "step over" or use the hotkey "F6" to go one step forward in the code execution
Take another look at the "variables view" the current value of "$X" should be now "8"
This way you can neatly study how your code and values changes step by step, you can also hover your mouse pointer over the variables names in the editor Eclipse IDE will pop up the current value of them.
Keep going froward until the end of the lines of code, at that point the web browser should display the final web page output

Categories