473,394 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

PHP modules

A quick question, I'm about to recompile PHP, last time I compiled it
with alot of modules, thinking that this time I should not need that
many. Is there any tool(s) that could run under the htdocs and scan
the PHP and tell me what modules actually being use? Thanks.

Jul 17 '05 #1
9 2310
sa****@gmail.com wrote:
A quick question, I'm about to recompile PHP, last time I compiled it
with alot of modules, thinking that this time I should not need that
many. Is there any tool(s) that could run under the htdocs and scan
the PHP and tell me what modules actually being use? Thanks.


Hi,
Make a php page that uses this function: phpinfo()
So, something like this:
<?php
phpinfo();
?>
That will give you useful info about the current PHP installation AND
will give you a list of installed mods.

-Ivan Filippov
Jul 17 '05 #2
<sa****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
A quick question, I'm about to recompile PHP, last time I compiled it
with alot of modules, thinking that this time I should not need that
many. Is there any tool(s) that could run under the htdocs and scan
the PHP and tell me what modules actually being use? Thanks.


No such tool exists as far as I know.
Jul 17 '05 #3
You could run the following command and see what modules you have
installed then look up the description of each and decide if you want
to enable them again.

#./httpd -l

When you are ./configure the command to enable alot of modules is.

--enable-mods-shared=most

check out link for more details.

http://httpd.apache.org/docs-2.0/pro...configure.html

Jul 17 '05 #4
Would that only be for the Apache modules and not the PHP modules?

Jul 17 '05 #5
Thanks, but I'm trying to elimate modules that don't need anymore, the
phpinfo() only provide me what is installed but not what is used. Any
other thoughts?

Jul 17 '05 #6
thinking there wasn't any but it was worth a shot. Thank you.

Jul 17 '05 #7
Since there isn't any program written to check for module usage of your
current website, I decided to write on myself, hope this might be
helpful to others.
<?php
/*
This script is to use to see if any of the web pages is using
the loaded modules, it will parse all php files of a given't path to
search every page
for those functions that might be associated with the modules.
This is useful if you have many modules compile in the current version
of PHP but
wanting to upgrade with less modules and not knowing which module
functions the programmer
might have used.

saidevATgmail.com
*/
//get all extensions that are loaded
$loadedExt = get_loaded_extensions();
$extFuns = array();
$fileslist = array();
$pathToCheck = "doc root"; //replace doc root with your document root
directory
$fileslist = getAllPHP($pathToCheck);
//there might be files with no read permission, avoiding getting
warning message
ini_set("display_errors",0);
foreach ($loadedExt as $ext) {
//skipping some standard modules
if (strtolower($ext) != "standard" && strtolower($ext) != "sybase_ct"
&&
strtolower($ext) != "session" && strtolower($ext) != "mysql" &&
strtolower($ext) != "gettext") {
echo "Scanning Module <strong>$ext</strong><BR>";
//get all functions for current scanning modules
$extFuns = get_extension_funcs($ext);
//loop thru each module functions
foreach ($extFuns as $function) {
for ($i = 0 ; $i < count($fileslist); $i++) {
$fileRead = fopen($fileslist[$i],"r");
$fileContent = fread($fileRead,filesize($fileslist[$i]));
if (ereg($function,$fileContent)) {
echo "<strong>$function</strong> used in ".$fileslist[$i]."<BR>";
}
unset($fileContent);
fclose($fileRead);
}
}
}
}
ini_set("display_errors",1);
//get all php files from given directory
//modified version of Jason Wong @
http://us3.php.net/manual/en/function.readdir.php example
function getAllPHP($dir) {
$file_list = '';
$stack[] = $dir;
while ($stack) {
$current_dir = array_pop($stack);
if ($dh = opendir($current_dir)) {
while (($file = readdir($dh)) !== false) {
if ($file !== '.' AND $file !== '..') {
$current_file = "{$current_dir}/{$file}";
if (is_file($current_file)) {
if (eregi(".php",$file) || eregi(".inc",$file)) {
$file_list[] = "{$current_dir}/{$file}";
}
} elseif (is_dir($current_file)) {
$stack[] = $current_file;
}
}
}
}
}
return $file_list;
}

?>

Jul 17 '05 #8
Yes, Sorry my example was only for apache modules. For php you can type
#php -m at a shell prompt to get a list of modules.

Good job on the code. Looks pretty useful for people who don't have a
predefined set of code and no that they aren't going to need any other
modules in the future. I'm sure people will get use out of that if they
want to trim down on the number of modules they have installed.

Just to be devils advocate here. I am wondering if installing a bunch
of extraneous modules will slow down the performance of PHP? It seems
like if you are doing development work you would want to enable most of
them in case you run into a problem that might require ldap or GD.

If you are administering a production box and the php code isn't going
to be changing any time soon, I think this code will come in handy.

Jul 17 '05 #9
saidev wrote:
Thanks, but I'm trying to elimate modules that don't need anymore, the
phpinfo() only provide me what is installed but not what is used. Any
other thoughts?

Here's a bit of code that will list the functions available in your
current installation. If, instead of printing them out in an unordered
list, you used the $f array in the script as the basis for digging
through your site code, looking for instances of those functions, you'd
be pretty close to what you want. I'd go through, and if an instance is
found, cull it from the array. When you've looped through all of your
code, the remaining functions have never been invoked in your code and
you'll have a list of functions you don't use, which should pretty
quickly point out which extensions you don't use.

------------------------------

<h2>Get Available Functions</h2>
Below is a list of all of the functions available to your PHP scripts.
After enabling other extensions, their functions will appear here.
Clicking on a function name will bring up the PHP manual page for that
function.

<?php

function usort_cmp($a, $b) {
return (strtolower($a) == strtolower($b)) ? 0 : (strtolower($a) >
strtolower($b)) ? 1 : -1;
}

echo "<UL>\n";
$le = get_loaded_extensions();
usort($le, "usort_cmp");
foreach($le as $module) {
print "<LI>$module\n";
print "<UL>\n";

$f = get_extension_funcs($module);
usort($f, "usort_cmp");

foreach($f as $func) {
print "<LI><a href='http://www.php.net/manual/en/function." .
str_replace("_", "-", $func) . ".php'>$func</a>\n";
}
print "</UL>\n";

}
echo "</UL>\n";

?>
J Wynia
Sokkit - web server toolkit for Windows
http://www.sokkit.net
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dave | last post by:
Hi Everyone, I am trying to import a package and then loop through the modules inside the package, but I'm running to a problem. Basically: ----- I have a package called...
0
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is...
15
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that...
7
by: Jorgen Grahn | last post by:
I have a set of tests in different modules: test_foo.py, test_bar.py and so on. All of these use the simplest possible internal layout: a number of classes containing test*() methods, and the good...
4
by: Misto . | last post by:
Hi folks! Short: There is a way to dumplicate a module ? I tried copy.deepcopy(module) but hangs with an error (also with standard modules ).. The only solution that I have by now is...
2
by: James Buchanan | last post by:
Hi group, I'm preparing Python 2.4.2 for the upcoming Minix 3.x release, and I have problems with make. configure runs fine and creates the makefile, but right at the end ends with an error...
7
by: Lauren Quantrell | last post by:
At running the risk of asking how big is too big... Is there a rule of thumb or a best practice that says I may have too many modules? I currently have a Access2K app with about 30 code modules,...
13
by: Robin Haswell | last post by:
Hey people I'm an experience PHP programmer who's been writing python for a couple of weeks now. I'm writing quite a large application which I've decided to break down in to lots of modules...
173
by: Zytan | last post by:
I've read the docs on this, but one thing was left unclear. It seems as though a Module does not have to be fully qualified. Is this the case? I have source that apparently shows this. Are...
3
by: Mohamed Yousef | last post by:
Hello , The problem I'm asking about is how can imported modules be aware of other imported modules so they don't have to re-import them (avoiding importing problems and Consicing code and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.