Skip to content
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

Enable Magento_Profiler by SetEnv #4

Closed
mzeis opened this issue Dec 15, 2011 · 5 comments
Closed

Enable Magento_Profiler by SetEnv #4

mzeis opened this issue Dec 15, 2011 · 5 comments

Comments

@mzeis
Copy link
Contributor

mzeis commented Dec 15, 2011

As of Magento 1, you have to edit index.php to activate Magento_Profiler.
In my opinion, it should not be necessary to edit any core files.

My proposal is to introduce code to app/bootstrap.php similar to:

if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}

One or more additional environment variables can allow to register the profile output classes.

Advantages:

  • No need to edit app/bootstrap.php
  • It's easy to set different settings for every environment (dev/stage/live etc.)
@stephpy
Copy link

stephpy commented Mar 13, 2012

What do you think about having a "index_dev.php" or somethink like this.

As we have it on Symfony or other frameworks.
By this way, you don't need to define a var or something else ...

@magento-team
Copy link
Contributor

Hi mzeis --

Currently in app/bootstrap.php the profiler enabling is hard-coded like this:

#Magento_Profiler::enable();
#Magento_Profiler::registerOutput(new Magento_Profiler_Output_Html());
#Magento_Profiler::registerOutput(new Magento_Profiler_Output_Firebug());
#Magento_Profiler::registerOutput(new Magento_Profiler_Output_Csvfile(__DIR__ . '/var/log/profiler.csv'));

How would you suggest to organize the $_SERVER variables, so that we'd have ability to enable any of profilers and not have to hardcode at the same time?

@mzeis
Copy link
Contributor Author

mzeis commented Mar 15, 2012

Hi,

I suggest the following solution:

--- a/app/bootstrap.php
+++ b/app/bootstrap.php
@@ -89,7 +89,6 @@ if (file_exists($classMapPath)) {
     Magento_Autoload::getInstance()->addFilesMap($classMapPath);
 }

-#Magento_Profiler::enable();
-#Magento_Profiler::registerOutput(new Magento_Profiler_Output_Html());
-#Magento_Profiler::registerOutput(new Magento_Profiler_Output_Firebug());
-#Magento_Profiler::registerOutput(new Magento_Profiler_Output_Csvfile(__DIR__ . '/var/log/profiler.csv'));
+if (isset($_SERVER['MAGE_PROFILER_ENABLED'])) {
+    Magento_Profiler::enable();
+}
  1. Enable the profiler using SetEnv.
  2. Configure the profiler output formats in an existing XML file (e.g. local.xml) or in the admin panel. The list of output classes is only accessed when Magento_Profiler::display() is called so you have plenty of time to register output formats when reading the configuration from XML files or core_config_data.

This way profiling gets more comfortable and flexible. You can extend existing profiler formatters or create new ones, you can create a handy configuration interface.

@magento-team
Copy link
Contributor

We have implemented enabling profiler, as well as the output, in bootstrap by specifying MAGE_PROFILER environment variable. The value can be 'csv', 'firebug' or any other for HTML. You'll see it in the source code with next update.

@mzeis
Copy link
Contributor Author

mzeis commented Mar 21, 2012

Thanks!

maksek pushed a commit that referenced this issue Dec 26, 2014
MAGETWO-32077: [GITHUB] Fix spelling error in Customer module xml :Magento Go #853
@alicedfisheye alicedfisheye mentioned this issue May 14, 2024
5 tasks
@FabXav FabXav mentioned this issue Oct 11, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants