PHP file automatically deleted

Hi there.
I’m using Wordpress on my website

The system automatically deleted 2 plugins PHP files of less than 2MB and Wordpress doesn’t work.
I tried to split in 3 files of less than 1MB and the sytem accept them, but I had to declare 3 times one PHP class so this isn’t work cause I can declare a class only one time.

What can I do?


Thanks, I understood the PHP max file size is 1MB.
Now my question is: how can I split my big PHP file in two files since the entire file is based on a “class” declare?

Use require function.

Make one contain the class declare, and the other holds the code.

1 Like

I’m already implementing the files trough the require function.
The problem is this:

file1.php starts like…
static function FUNCTIONHERE() {
code of the function

file2.php is the same, so I get an errore because I declared 2 times the same class.
If I try to declare the class in only one file, how can I add the code of the 2nd file in the same class?

A particular class can only be defined once in PHP. Some programming languages allow you to dynamically change the definition of a class (called “monkey patching”), but PHP doesn’t really support that.

So you’re going to have to use different class names for the class in file2.php. That doesn’t mean you have to duplicate all code though, you could use class inheritance to integrate functionality from the class of file1.php into the one of file2.php.


Make one file the class, then put the function in another file.

1 Like

Can you make a example please?

This is psuedo-code.
Class here
require(‘FILE 1’);
function here

1 Like

Recap: I have one big file with only 1 class and only 1 function.
So, as you said, in the FILE 1:

class something_here {
   function_here {
      code here

… and in the FILE 2:

      still more code here

Like this nothing is working, with error " Parse error : syntax error, unexpected ‘}’, expecting end of file in … file here"

What, is the class file to big to fit in one file?

1 Like

Yes! 2MB if I want to upload only 1 file…

10 MB is the max I think. But htaccess is 1 MB.

No, you’re wrong with the .htaccess deletion thing. .htaccess files will be deleted if they weigh more than 10 kBs, while HTML and PHP files bigger than 1MB and other types of files that weigh more than 10 MB will be deleted.


The first question is: what on earth is in your PHP files that they are so big in the first place. A normal PHP file with regular code is typically no more than a few hundred KB in size, hence the 1 MB file size limit.

Some tools pack arbitrary data (like images or other data) into PHP files as well. This can be a good method to prevent them from being accidentally opened in browsers, at a quite steep cost to server performance.

If that’s the case for your file as well, the best way to deal with that is to cut the arbitrary data out of the PHP file and into a separate file with a different extension. The remaining PHP code could then be altered to read the data from the separate file.

If the data you cut out is sensitive, you could use .htaccess rule to restrict access to these files instead.


Yes, I know that.
The file that I’m editing is a configuration file of the tagDiv Wordpress Plugin that is required in order to use my Wordpress theme…
It’s very long and is about 1.8MB and I don’t know how can I split it in 2 files.
There are no images or other data, there is only PHP code with about 40.000 rows…

Would you like me to take a look at the file and help you split the file? If so, can you please share the path of the file so I know where to look?


Yes of course.
I uploaded the original PHP file, because the files on the host are edited and splitted.
Original file: MEGA

File 1 Path: wp-content/plugins/td-composer/legacy/Newspaper/includes/td_config1.php
File 2 Path: wp-content/plugins/td-composer/legacy/Newspaper/includes/td_config2.php

Well, that’s an interesting way to describe a lot of configuration in one, big PHP file!

In it, I see one PHP class td_config with many different static functions, each returning some hard coded or almost hard coded data.

To split this file, I would probably do the following:

Create a file like td_config_part1.php. In it, create a PHP class like so:


class td_config_part1 {
// put functions here

Within this class, you can paste roughly half of the functions of the original file. It doesn’t really matter which ones you use, as long as you copy only the whole functions.

Then, you can create a second file td_config_part2.php. This file should be slightly different from the first part, and look like:


class td_config_part2 extends td_config_part2 {
// put functions here

Paste the other half of the functions in this file.

You’ll now have a class td_config_part2 which has both it’s own functions and the functions which it inherited from td_config_part1.

Finally, you’ll want to edit the original td_config.php so it uses the functions from the part files. So you’ll want to replace this part:

 * speed booster v 3.0 hooks - prepare the framework for the theme
 * is also used by td_deploy - that's why it's a static class
 * Class td_wp_booster_hooks
class td_config {
// all of the functions

With something like:

require_once 'td_config_part1.php';
require_once 'td_config_part2.php';

class td_config extends td_config_part2 {
// nothing here

This should give you a PHP class td_config which has all the same functions as the original class, but now split over multiple files.

And if you need to add more functions, you can simply add parts 3, 4, etc. by chaining them just like you chained part 2, with part 3 extending 2 and 2 extending 1.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.