Re: dependency check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 22, 2011 at 8:17 AM, Nilesh Govindarajan
<contact@xxxxxxxxxxxx>wrote:

> On 07/22/2011 11:21 AM, Andreas Moroder wrote:
> > Hallo,
> >
> > I have a PHP application made of many files ( php, images etc. )
> > I have a strong suspicion that many of the files in the application
> > directory are no more in use, because of changes made on the application.
> > Is there a tool that, starting from the entry point of the application,
> >  scans the files recursively for included/used files and lists them ?
> > With this list I could delete the remaining files.
> >
> > Thanks
> > Andreas
> >
> >
>
> You could write a python or even php script to do that, storing all the
> files an array/list and then finding files (regex) which are not
> included in any of the php files.
>
> Of course, this applies if and only if you haven't used __autoload() magic.
>
> --
> Regards,
> Nilesh Govindarajan
> @nileshgr on twitter/identica
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


Or you could just grep the directory, not saying you have to do this, but
this was kind of fun to write anyways, if i spent more time on it, i could
perfect it, but i dont have that kind of time, so this will still give you a
few doubles, but it shouldn't give you false-positives as long as you have
all the extensions in that grep regex (and you cant make it more generic
without introducing false-positives)...

grep -oiPR "[a-zA-Z0-9]+\.(php|js|png|
jpg|css|htm|html)" directory | awk 'function getfiles(input, files, i, n,
file) {result = ""; n=split(input, files, ":"); for(i=0; i<=n; i++) {
if(files[i] !~ /^\s*$/) print files[i];}} {getfiles($0)}' | sort -biu

This should give you all the files that reference files and the files they
reference.

--
The trouble with programmers is that you can never tell what a programmer is
doing until it’s too late.  ~Seymour Cray

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux