How to track the execution of php file by console?

0
  

Update update: Actually my problem had nothing to do with this snippet of blockquote underneath. I learned to debug PHP, and I encountered several errors, but I will not even go into each one of them because it's not the case ... So, having solved it in a different way, Guilherme's comments and answers helped me to understand some concepts, and as I think it can help other users, I decided not to remove the question and accept the answer.

-.-

  

Update: I found the problem, which is in this section:

 <blockquote>
        <strong> <em>RECURSO DE REVISTA. [...] RESCISÃO DO CONTRATO DE TRABALHO - NULIDADE - AUSÊNCIA DE ASSISTÊNCIA SINDICAL.
        O objetivo da assistência sindical no pedido de demissão decorre da consagração do princípio da
        irrenunciabilidade dos direitos trabalhistas. Retrata o art. 477, § 1º, da CLT, norma cogente, que condiciona
        o pedido de demissão e a quitação do contrato de trabalho firmado pelo empregado cuja relação jurídica vigorou
        por mais de um ano, à assistência perante o Sindicato. Nesse sentido, a formalidade determinada pela norma, se
        não cumprida, torna nulo o ato. Incumbe ao empregador o cumprimento da formalidade prevista no art. 477, § 1º,
        da CLT, sob pena de não se convalidar o pedido de demissão, quando não houver a homologação, nos
        termos previstos na norma. Precedentes. Recurso de revista conhecido e provido. [...]</em></strong> (TST   PROCESSO Nº
        TST-RR-256-42.2010.5.02.0088, 6ª Turma, Relatora Desembargadora Convocada CILENE FERREIRA AMARO SANTOS,
        Data de Julgamento: 10/12/2014 - grifos nossos)
    </blockquote>

And the problem seems to be inside the text itself, I thought it was the use of brackets, but I do not think it is, I tried to escape with \ and it did not work.

In fact, this other part is also giving the same problem (I have tested only one part, without the other, and it gives the same problem):

<p>
            <?php echo $motivdesligjust; ?>
            <?php echo "<br>"; ?>
        </p>
        <p>
            <?php echo $motivdesligind; ?>
            </p>

Can not I call the variables inside the <p></p> ? tags

/ update

I'm having a problem here in running a php file, which uses include to include other files, and I can not figure out the cause. It seems to be an infinite loop, but I'm not using for , while , nothing, I just call variables escaping html, and I use a if or another ...

The file is running in the browser and not for more, it is the message "Waiting for localhost", and after that no other php file can run before I reset phpstorm.

So I wanted to know if there is any command for me to track the execution, and to know why it is running in this infinite loop.

It is a strange error because there are several files included by include , and if I remove the first 3 for example, it works, and the same happens if I leave only the first three, but I have already rolled the files and I can not find the problem.

    
asked by anonymous 04.07.2015 / 19:09

1 answer

2

As you ask in the SOen there are some tools for this, such as:

monolog

Installing with composer:

$ composer require monolog/monolog

Basic usage example:

<?php

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$log = new Logger('name');
$log->pushHandler(new StreamHandler('pasta/seu-arquivo-de-log.log', Logger::WARNING));

// Adiciona gravações para o log
$log->addWarning('Foo');
$log->addError('Bar');

phptrace

(I'm not sure, but I think it only works with FPM, apache2handler which is more common on windows with apache might not work)

  • Extract the extension:

    tar -zxf phptrace-{version}.tar.gz
    cd phptrace-{version}
    
  • Compile the extension

    cd extension
    {php_bin_dir}/phpize
    ./configure --with-php-config={php_bin_dir}/php-config
    make
    make install
    

    (in case if it is windows and mingw you will probably have to use mingw32-make )

  • Copy the compiled extension to the php extensions folder and edit php.ini

    extension=trace.so
    
  • Compile commandtool

    cd cmdtool
    make
    
  • Testing if the installation is ok:

    php -r 'for ($i = 0; $i < 100; $i++) usleep(10000);' & ./phptrace -p $!
    
  • 04.07.2015 / 19:44