I have to use an old not well documented php CMS. I need to edit and add some codes which has weird hierarchy and i can't find the root file or the files in between which are needed to make change in stuff. Is it possible to find the file included this one or run before it? the main goal is to find full hierarchy but this should be enough to find them one by one.
Asked
Active
Viewed 74 times
1
-
2Get yourself a decent **[Integrated Development Environment (IDE)](https://en.wikipedia.org/wiki/Integrated_development_environment)**, it will save you a lot of time and pains. – YvesLeBorg Jul 30 '18 at 12:18
-
I've already got vscode, but my problem is this sh*tty code has many refactoring and modular stuff which i can't find my way through them... – no0ob Jul 30 '18 at 12:20
-
1While you can do a lot of stuff in vsc, especially with plugins, it's still more a 'code editor' and not an 'IDE' as such. You want something with advanced debugging and tracing – Nanne Jul 30 '18 at 12:29
3 Answers
2
You don't want to spread debug code and vardumps all over the place: look into debugging and step trough your code. This is a bit of a learning curve but will help you.
For instance, use phpstorm and xdebug.
If you are set on using vscode, google says there are plugins for xdebug as well, so don't let that stop you: https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug
Every debugsession where you need to plaster var_dump
and backtraces in your code is one that is costing you more time then it should -> sure, setting this up takes some time, but spent it. Even if it takes a day :D

Nanne
- 64,065
- 16
- 119
- 163
-
thanks but i got what i exactly wanted from Michal Bieda. +1 for the xdebug, i can't afford phpstorm yet :)) – no0ob Jul 30 '18 at 12:34
-
I'd still suggest to try it out, it's a bit of time now but you'll have your time back in no-time. Even for vscode there are plugins! https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug (says google). It's a really, really, really good skill to have – Nanne Jul 30 '18 at 13:05
-
I currently struggle with using xdebug on vscode, i know it's separate question but i think my problem there is that i have separate `php` installation for the VS and Wamp and i don't know how to change it on VS -_- – no0ob Jul 31 '18 at 03:33
-
1I'm not sure what that means precisely, but if you have a WAMP with xdebug it will 'send' the "i'm doing this file now!" information to your IDE. All you need to do is catch that information (listen to an incomming port, auto-accept or accept on a certain key from your browser request) and map the files on your server to the files in your ide (e.g. "the server calls this file `/var/www/index.php` but the IDE calls it `/home/no0ob/projects/myproject/index.php` so it knows what line to show. – Nanne Jul 31 '18 at 09:15
-
https://stackoverflow.com/a/13156071/7681658 something like this maybe, i'm on windows and i installed VSCODE before wamp so it's php were not env path, and VSCODE asked to install php for it specifically but i fixed it from `"php.validate.executablePath"` but still there is no stop on breakpoints ... – no0ob Aug 01 '18 at 08:50
-
i found the problem! i had to use phpstorm marklets from https://www.jetbrains.com/phpstorm/marklets/ – no0ob Aug 01 '18 at 09:55
0
$files = get_included_files();
$section_data_array = array();
$total_size = 0;
$largest_size = 0;
if (is_array($files)) {
foreach ($files as $file) {
$size = filesize($file);
$section_data_array[] = array('data' => $file, 'size' => $size);
$total_size = bcadd($total_size, $size);
if ($size > $largest_size) {
$largest_size = $size;
}
}
// endforeach;
unset($file, $size);
}

Sandeep Bangarh
- 12
- 5
-
This gets all included files, calculates their total file size, determines the largest file size (without remembering the name of the file) and outputs nothing. The array $section_data_array is filled, but never used. I did not downvote this answer, because it made me smile. :) – Leif Jul 30 '18 at 13:02