Recently I was working on a PHP code that requires 15 classes (15 files) in the start of the php file, and then depending on posted values uses 1 or two of them. This classes together are 8000 lines of code. I want to use PHP autoload (I know how it works), but I want to be sure If my decision is right, and what I gain using autoload and what I am loosing when I am not using it, for example how many KB will be 50KB of PHP code in RAM . I searched several hours and couldn't find answer to my question. How PHP read classes that aren't used in code. Is he building, registering class or is he wait for calling the class for doing the work needed. I can't find any resource, which precisely describes how PHP works.
Asked
Active
Viewed 27 times
0
-
I was searching for hours and wasn't able to find any answer, send me the answer, please – Hovhannes Babayan Dec 02 '15 at 19:49
-
What were you doing all these hours? Take a look at the answer to the duplicate question, and if it doesn't answer everything you need to know, update your question to ask about the new part. (PS. About how much memory PHP will use with/without autoloading: Try it and see for yourself!) – alexis Dec 02 '15 at 19:59
-
How I will now how much it is using? How PHP shows how much RAM it allocates for calling 50KB of code? The answer is not satisfying at all, – Hovhannes Babayan Dec 02 '15 at 20:01
-
1Reference [`memory_get_usage`](https://secure.php.net/manual/function.memory-get-usage.php). Try with and without autoloading. – Yoshi Dec 02 '15 at 20:03
-
Thanks Yoshi, but as professionals you could tell me approximately how much will it take, for example 20mb ram etc – Hovhannes Babayan Dec 02 '15 at 20:04
-
2@Hovhannes, if you prefer some "professional's" guesstimate over something you can easily measure yourself for real, You Are Doing It Wrong. Learn how to help yourself-- that's what this site is for. – alexis Dec 02 '15 at 20:13
-
Honestly, I would not even bother checking. The pros of having an autoloader are so overwhelming that everything else is just not worth it. If, after all, you really need that extra *bit*, use an autoloader with a good cache. Try [composer](https://getcomposer.org/) for example. – Yoshi Dec 02 '15 at 20:15
-
Thanks I'll do that, alexis in the other I want some numbers for the other developers to read this post in the future, I even wasn't able to find how apache server allocates place in ram for code, there is so much mess in the net, that google search doesn't bring satifying answers for my question – Hovhannes Babayan Dec 03 '15 at 04:14
-
I did memory check, and it uses 7.5 mb only for calling classes (80KB of code), and 2.5 without calling them. In peak hours there are 200 calls per second, – Hovhannes Babayan Dec 03 '15 at 06:14