Yii Framework Forum: Tracing Yii Execution: What Elements Make Up A Page? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Tracing Yii Execution: What Elements Make Up A Page? Rate Topic: -----

#1 User is offline   Jonah11 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 24-December 10

Posted 08 January 2011 - 03:44 AM

As a newb to Yii who is working with a fairly large existing application, I am having trouble following the execution path, and determining which widgets and other Yii elements are being rendered to the page. Is there a good method for this? Perhaps a debug mode? Or if not, just a general algorithm for the steps I should take, starting with a url, to determine everything that is ultimately included on the page?

Thanks,
Jonah
0

#2 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,834
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 08 January 2011 - 04:05 AM

View PostJonah11, on 08 January 2011 - 03:44 AM, said:

As a newb to Yii who is working with a fairly large existing application, I am having trouble following the execution path, and determining which widgets and other Yii elements are being rendered to the page. Is there a good method for this? Perhaps a debug mode? Or if not, just a general algorithm for the steps I should take, starting with a url, to determine everything that is ultimately included on the page?

Thanks,
Jonah


First steps:
1. Read the introduction to Yii execution flow here.

2. You should enable web or file logging and study the logs.

/Tommy
Don't forget to read The Definitive Guide to Yii (1.1/2.0 en) | The class reference (1.1/2.0) has the details
0

#3 User is offline   Jonah11 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 24-December 10

Posted 08 January 2011 - 04:36 AM

View Posttri, on 08 January 2011 - 04:05 AM, said:

First steps:
1. Read the introduction to Yii execution flow here.

2. You should enable web or file logging and study the logs.

/Tommy


Tommy, thank you for the links. Regarding Yii::trace(), I am a bit confused. How would I use it? Is there a place I can globally say "trace everything and display it"?

Jonah
0

#4 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,834
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 08 January 2011 - 05:28 AM

View PostJonah11, on 08 January 2011 - 04:36 AM, said:

Tommy, thank you for the links. Regarding Yii::trace(), I am a bit confused. How would I use it? Is there a place I can globally say "trace everything and display it"?

Jonah


  • "What makes up a page" is of course application dependent.
  • The section Fundamentals->View of the guide may be useful (reading all of the guide thoroughly is recommended)
  • You have to add trace() calls yourself.
  • Also intentionally add errors and study the stack trace.
  • Try increasing YII_TRACE_LEVEL in start script to include deeper stack trace in logs.
  • Add more levels to file logging (or just leave levels empty)

    ...
    'log'=>array(
      'class'=>'CLogRouter',
        'routes'=>array(
          array(
            'class'=>'CFileLogRoute',
            'levels'=>'error, warning, trace, info',
          ),
        ),
    ),
    ...
    

/Tommy
Don't forget to read The Definitive Guide to Yii (1.1/2.0 en) | The class reference (1.1/2.0) has the details
0

#5 User is offline   Jonah11 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 24-December 10

Posted 08 January 2011 - 02:15 PM

Tommy,

Thanks again. I have read the logging section in the docs a couple times, and I still can't figure out how I would actually use it in my code. I tried putting a call to Yii::trace('test', 'system.web.CController') in one of my source files being executed but it didn't seem to have any result. Can you give a quick code example? And afterwards, will I be looking for a log in the runtime folder, or is there some way to have the trace printed directly to the screen?

Thanks,
Jonah
0

#6 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,834
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 08 January 2011 - 02:51 PM

View PostJonah11, on 08 January 2011 - 02:15 PM, said:

Tommy,

Thanks again. I have read the logging section in the docs a couple times, and I still can't figure out how I would actually use it in my code. I tried putting a call to Yii::trace('test', 'system.web.CController') in one of my source files being executed but it didn't seem to have any result. Can you give a quick code example? And afterwards, will I be looking for a log in the runtime folder, or is there some way to have the trace printed directly to the screen?

Thanks,
Jonah


Make sure the following line isn't commented out in the startskript
defined('YII_DEBUG') or define('YII_DEBUG',true);


You don't need to specify the category parameter, it defaults to 'application' for your trace calls (contrary to 'system'). I added an example below. It will log every level and category to both file and to the web page. As you already found out, the log file is written to protected/runtime/appplication.log.

array(
  ...
  ...
  // preloading 'log' component
  'preload'=>array('log'),
  ...
  ...
  'components'=>array(
    'log'=>array(
    'class'=>'CLogRouter',
      'routes'=>array(
        array(
          'class'=>'CFileLogRoute',
          //'levels'=>'...',
          //'category'=>'...',
        ),
	array(
          'class'=>'CWebLogRoute',
          //'levels'=>'...',
          //'category'=>'...',
	),
      ),
    ),
    ...
    ...
  ),
  ...
  ...
);

/Tommy
Don't forget to read The Definitive Guide to Yii (1.1/2.0 en) | The class reference (1.1/2.0) has the details
0

#7 User is offline   Jonah11 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 24-December 10

Posted 08 January 2011 - 03:57 PM

Thank you very much! Working now.... Don't suppose you might be interested in:

http://www.yiiframew...ng-immediately/
0

#8 User is offline   Jonah11 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 24-December 10

Posted 08 January 2011 - 04:06 PM

One other question. The trace I see seems to be at a pretty high level of abstraction. I wanted to see how certain widgets and filters with those widgets, etc, were being called. Is there any way to do this?
0

#9 User is offline   DarkNSF 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 287
  • Joined: 12-November 08
  • Location:Palm Bay, Florida

Posted 08 January 2011 - 06:01 PM

View PostJonah11, on 08 January 2011 - 04:06 PM, said:

One other question. The trace I see seems to be at a pretty high level of abstraction. I wanted to see how certain widgets and filters with those widgets, etc, were being called. Is there any way to do this?


You could hook your application up to a php debugger to see all of the inner workings step by step
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users