Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8376347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:24:47+00:00 2026-06-09T15:24:47+00:00

I am building a testing tool to execute on directories of legacy PHP code

  • 0

I am building a testing tool to execute on directories of legacy PHP code that is extremely difficult to unit test, although I am using PHPUnit for this tool.

One of the cool things about PHPUnit is that it will bubble up PHP notices, warnings, and errors into an exception. Using that bit of knowledge I’ve built a tool to recursively include() files from a directory in a try/catch block and log any exceptions.

The problem is, this can quickly become a memory hog and crash if I include hundreds of files. I’ve considered using this but I’m not sure if this “clears” it from memory:

// Include file into buffer
ob_start();

include($file);

// Clear file from buffer
ob_clean();

What is the best way to handle something of this nature and manage memory/resources appropriately?

[EDIT]

Also, this is an internal tool that I am developing to help manage the thousands of files containing untestable (in a time constraint sense) legacy procedural code.

What about this as a thought?

// Enable garbage collector (in case this helps?)
gc_enable();

// Get procedural php and execute it
$fileData = file_get_contents($file);
eval($fileData);

// Clear variable
$fileData = null;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:24:48+00:00Added an answer on June 9, 2026 at 3:24 pm

    What if you create a separate CLI script (the “tester”) that will include one file at a time and log the exceptions, and have your main script (the “iterator”) iterate through / recurse into the directories of scripts you need to test and invoke the tester script via the shell for each file?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using NUnit for testing back-end. Unit tests are being executed while building (I'm
I'm using TeamCity Professional for building and testing my code continually. I have some
I'm building a regression system ( not unit testing) for some Perl scripts. A
I'm new to Unit Testing, and I'm only getting into the routine of building
I'm using XCode 4.2 and testing my build on iPad 5.0. I started building
I'm following this tutorial on building a widget IN that tutorial, he's testing whether
I know that Jenkins is focused on continous building/testing, monitoring of batch jobs about
I am building a tool for out-of-container EJB testing. I have managed to run
I've been building PHP tools with a MySQL backend. Using multi-curl I can run
I am building a validation for testing to make sure that a correct part

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.