What is the average number of files in a web app?

Hello all,

This may be an odd question, but what is the average number of files in a web application?

I ask because I am building a student manager app as a personal project (that manages courses, teachers, students, grades etc.) and so far it has 70+ files and it’s not finished yet. Note that the number is including JS, HTML and CSS. When it’s done I can see it being around 90+. I am designing it to be OOP and I use a “one class per file” style, and the classes do one thing like “Select all Students” or “Login User” and on average have 40 lines of code. Also different files for the interfaces and the PHP pages that get $_POSTS from the client. I may have to rethink my design if it’s too much.

I know that it depends on the design of the app, but when you’re building a PHP app how many files do you make on average? Or doesn’t it matter so long as the app works?

I think you worry about this because of the performance. And I would say it doesn’t matter, you don’t have to worry about that. Only one thing you need to worry that your code is well structure and easy to maintain, because PHP already have opcode cache what will make your code fast even though you have a thousand of files. Other than that, js/css can be optimize by minify them too. But more files is more complicate to maintain, so you take care of it. Good luck! :slight_smile:

As many or as little as it takes to get your program working…

You could have 10 different people create the exact same website in PHP, and you will have 10 very different amounts of code written…so as mentioned above, just make sure you are making code that is easy to maintain.

And just something to keep in mind, the less code you write to get something done, the better.

Out of curiousty I checked a few apps I have
WordPress 2,159 files 212 folders
old phpBB2 1,706 files 37 folders
Discourse 6,965 files 428 folders

*hint, you don’t need to write all of your files at once :wink:

It’s just that with feature creep code bloat tends to happen.

I have been trying to follow a design of sorts, and I’ve been documenting as I go along, so that would help as well for the future. Haven’t thought of minifying them. The largest JS files I have are jQuery, and there’s compressed versions of that anyway. Haven’t seen minified CSS, though.

Not a problem, I don’t like typing a lot anyway. :smiley:

…and there, I thought I was being excessive.So I guess my app is just a baby. :slight_smile:

There’s no way I can write this all in one day though, you’re right. I’ve nearly spent a week on it so far. I also have the features that I want listed anyway, so I don’t think that I’ll be adding more.

It doesn’t matter how many files, as long as you have them logically organized. If you start getting 300 random php files shoved into a single folder, then you’re going to be in trouble down the road when you start forgetting all the little specifics about your app and want to change something.

However if you get around to it, you should start looking at some MVC frameworks. Or you can build your own MVC framework for your app. It’s kind of a paradigm shift, so you may be able to pack more powerful functions into less files without effecting readability.