Using single class in the all website script pages

I am having about one single class with about 3,500 lines of code, the whole website will be based on this class, so if the website has pages likes: member.php, login.php, signup.php, etc... all of them will use that single class to process most of the website functions.

Can that affect the server memory since it will probably load 3,500 line in the memory each time any member access any page?
LVL 12
Mohamed AbowardaSoftware EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MarsMCommented:
That would not be a problem. 3500 lines would be less than (say 100 characters per line) 350 kilobytes. Frameworks like cakephp have many more lines and that is also not a problem in my experience.
0
eriksmtkaCommented:
Each time a page is loaded, the PHP engine reads the file, parses it, compiles it and processes it.  So, it will be doing a lot of that.  The performance penalty would probably be minimal, but if I were you, I would only include what you need for each stage of the process.

One other thing you could do is look in to the "bcompiler" PECL library.  This will give you the benefit of already having the PHP engine "parsed and compiled" the code.
0
MarsMCommented:
Actually, php is not compiled. It is interpreted and this means that it is interpreted each time it is run. Only the part that is needed is interpreted and as I stated before, it is small some loading it is fast. Compiling php can be done, but if you want to change anything in the source code you will have to recompile it. The speedup is about 40% (if I remember correctly from articles). My advise is to just use the class as is unless you have a real high traffic site.
0
Ray PaseurCommented:
I usually agree with eriksmtka but this time I disagree.  The performance "penalty" associated with reading a file includes I/O overhead from disk.  This means locating the file, reading the file, etc.  Disk I/O operations are about 100,000 X slower than in-memory operations.  My preference is to load ONE large file, containing all of the classes, functions and definitions needed for the application.  No disrespect meant to the PHP guys who wrote the autoloader -- it's useful in a development and debugging environment and that is what they work in.  But as a practical matter in the world of high-performance web applications you want the minimum number of I/O operations and that means the fewest number of include() calls.

Memory is not a problem.  Just buy more.  It's amazingly cheap.  Same is true of disk storage.  A gigabyte of online storage costs about the same as the amount of toilet paper you use to wipe your ass.  It's just not worth trying to economize on these things at the expense of robust application performance.

Best regards to all, and Happy New Year, ~Ray
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.