Skip to content

Create new CLI command: enable/disable Magento Profiler #9277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vrann opened this issue Apr 17, 2017 · 12 comments
Closed

Create new CLI command: enable/disable Magento Profiler #9277

vrann opened this issue Apr 17, 2017 · 12 comments
Assignees
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line improvement Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed up for grabs

Comments

@vrann
Copy link
Contributor

vrann commented Apr 17, 2017

In order to help developers to work with the Magento, create new commands which will simplify the debugging of the application. Currently, enabling of these setting require doing that either with the UI or changing the configuration of the di.xml.

Create CLI command which will make possible to enable/disable Magento Profiler

SasiKiranK pushed a commit to SasiKiranK/magento2 that referenced this issue May 5, 2017
SasiKiranK pushed a commit to SasiKiranK/magento2 that referenced this issue May 5, 2017
SasiKiranK pushed a commit to SasiKiranK/magento2 that referenced this issue May 5, 2017
SasiKiranK pushed a commit to SasiKiranK/magento2 that referenced this issue May 5, 2017
@okorshenko
Copy link
Contributor

Hi @SasiKiranK please let us know if you are still working in this issue. Thank you

@osrecio
Copy link
Member

osrecio commented Jul 17, 2017

Can I help with this task?

@okorshenko
Copy link
Contributor

Hi @osrecio Sure! I will assign it to you. Thank you

@osrecio
Copy link
Member

osrecio commented Jul 25, 2017

Hi @vrann and @okorshenko , I have question about this task:

In file: app/bootstrap.php $_SERVER['MAGE_PROFILER'] is not empty.
The problem of this that you can do:SetEnv MAGE_PROFILER "html" in your .htaccess but you can have another HTTP Server like nginx.

Can I move this Enviroment Variable to env.php like MAGE_MODE ?

I think is better approach, I can keep 2 ways from $_SERVER and from env.php What do you think?

Thanks!

@magento-engcom-team magento-engcom-team added Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed improvement up for grabs labels Sep 11, 2017
@peterjaap
Copy link
Contributor

peterjaap commented Oct 12, 2017

@osrecio I don't think it's a good idea to move it to env.php. The reason being that env.php is not yet parsed by app/bootstrap.php by the time it now initializes the profiler, thereby eliminating the possibility to profile everything before the moment it parses env.php.

My suggestion would be to use a flagfile (like ./var/profiler.flag) to activate the profiler, and use the CLI command to add/remove it and set the profiler type (html, csvfile or something custom).

Quick write-out (I'll be happy to create a PR for it);

Instead of this part in app/bootstrap.php;

if (!empty($_SERVER['MAGE_PROFILER'])
    && isset($_SERVER['HTTP_ACCEPT'])
    && strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false
) {
    \Magento\Framework\Profiler::applyConfig(
        $_SERVER['MAGE_PROFILER'],
        BP,
        !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
    );
}

We use;

if (
    (!empty($_SERVER['MAGE_PROFILER']) || file_exists(BP . '/var/profiler.flag'))
    && isset($_SERVER['HTTP_ACCEPT'])
    && strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false
) {
    \Magento\Framework\Profiler::applyConfig(
        ((isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER']) ? $_SERVER['MAGE_PROFILER'] : file_get_contents(BP . '/var/profiler.flag')),
        BP,
        !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
    );
}

And then use php bin/magento dev:profiler:enable <type> (with type default html) and php bin/magento dev:profiler:disable to enable the profiler by creating the flagfile and disable the profiler by removing the file.

@osrecio
Copy link
Member

osrecio commented Oct 12, 2017

GO ahead with PR, I forgot this task :) . I think your idea is good, I like it like maintenance file, etc

Thanks @peterjaap

@peterjaap
Copy link
Contributor

peterjaap commented Oct 12, 2017

@osrecio 45 minutes booooom 🔥

@osrecio
Copy link
Member

osrecio commented Oct 12, 2017

You’re the best 😎

@okorshenko
Copy link
Contributor

Delivered to 2.2-develop branch.
The feature will be a part of 2.2.3

@okorshenko okorshenko added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Nov 15, 2017
@keharper
Copy link
Contributor

@peterjaap I need to know more about these commands so that they can be documented.

@peterjaap
Copy link
Contributor

@keharper

  1. It does not replace it per se, it is just another way to enable/disable the profiler. Also, this new command does not enable you to enable the dependency graph option.
  2. It will just enable it again (/still); https://github.com/magento/magento2/pull/11407/files#diff-30813cda1ee05b4cd04f143198b6d5e1R90
  3. No. It will give a warning in that case; https://github.com/magento/magento2/pull/11407/files#diff-30813cda1ee05b4cd04f143198b6d5e1R85

@magento-engcom-team
Copy link
Contributor

Hi @vrann. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1359 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line improvement Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed up for grabs
Projects
None yet
Development

No branches or pull requests

7 participants