Tracking the origin of generated code
Moderator: General Moderators
Tracking the origin of generated code
I have come to PHP via open source CMS but I want to understand PHP in more depth. The best way I found so far is tracking the flow of program execution but understanding which php files have contributed code to a finished page is very slow and demanding work. Maybe that's just the way it is for everyone learning? Maybe also there is a faster way like with a 'trace' function of some kind which comments each block of generated code with the name of the contributing module? (I cannot see any reference to such a facility in the PHP ref manual but maybe I look in the wrong place) Do I just keep on doing what I am already doing or is there a more efficient learning pathway?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Tracking the origin of generated code
GUI based debugging to the rescue.
NuSphere's PhpED is pretty nice, doesn't allow you to move backwards in program execution for some reason?
Zend also has the same functionality but I find zend studio to be a pain to use in practice, too many nuisances, phpEd is worth the 250% more in price to me
NuSphere's PhpED is pretty nice, doesn't allow you to move backwards in program execution for some reason?
Zend also has the same functionality but I find zend studio to be a pain to use in practice, too many nuisances, phpEd is worth the 250% more in price to me
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
Re: Tracking the origin of generated code
WinCacheGrind in the other hand helps you to find speed hogs.
Last edited by kaisellgren on Wed Oct 08, 2008 5:57 am, edited 1 time in total.
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Tracking the origin of generated code
Stepping through code is about the only way to learn unless you have superior docs -- which never exist.Maybe that's just the way it is for everyone learning
Re: Tracking the origin of generated code
With GUI based debugging you don't have to step along thru anything, you can just set breakpoints and run the debugger
also, file find and replace works wonders, any good editor will have a feature for locating files, for instance phpED lets me search within functions, classes, filenames, whatever I want
I find tutorials are docs are the best source of learning, and books too... stepping thru code is usually how I do it though ( which leaves you only half understanding it in most cases )
also, file find and replace works wonders, any good editor will have a feature for locating files, for instance phpED lets me search within functions, classes, filenames, whatever I want
I find tutorials are docs are the best source of learning, and books too... stepping thru code is usually how I do it though ( which leaves you only half understanding it in most cases )
Re: Tracking the origin of generated code
When I review a new PHP package, I almost always start by dropping this at the bottom of its index.php:
I also use this also quite a bit in optimizing code. Quite often files will get loaded that aren't even necessary.
Code: Select all
echo implode(get_included_files(), "\n");
Re: Tracking the origin of generated code
haha that reminds me, phpED ( and zend I think ) have a profiler, you can profile a page request and then see not only all the files that were included, which methods & classes were called, how many times each method was called, avg min and max time to execute, and sort on it all. The get included files thing is a great idea I wish I had thought of, before I discovered the magical world of IDEs
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Tracking the origin of generated code
Code: Select all
echo implode(get_included_files(), "\n");That's actually a really good idea...