PHP如何管理加载到内存中的函数?

I was developing a PHP project recently using Laravel Framework. I was wondering whether the unused functions/methods of PHP get loaded into memory?. I read that one of pros of interpreted languages that they have automatic memory management. However, this has not answered my question of whether they are loaded or not. Does this automatic memory management handle the case mentioned?

What actually happens to my memory when I run:

php artisan serve

Is my whole Laravel project being loaded into memory?

If yes, Is it my responsibility as a developer to handle loading commonly used functions/methods?, furthermore; how do I decide where to store it or on which principles? (Note: You do not have to explain it all to me, just redirect me to a manual)

If no, where does it stores its methods or functions(i.e. cache, swaps to hard disk)?Moreover, are they stored as plain code or they have been interpreted already for further use?

No it isn't all loaded into memory! That's because Laravel (like a great many PHP libraries and frameworks) uses an Autoloader that only loads what is needed to process the request, and only when it is needed.

However, if you are using opcache, it will load the bytecode to opcache and that will remain in opcache until cleared

PHP is a single-pass interpreter which means that source code is read starting at the top of the file, and a cursor moves forward parsing text into byte code.

Additional PHP source code is loaded on demand as the running cursor interprets includes or triggers a class loader.

The generated byte code is often stored in an opcache so that PHP files are not interpreted again.

When you make changes to a PHP file the web server has to tell the opcache the contents have changed, and the file needs to be interpreted again. You can configure production servers to not perform this check so that it increases performance. If you have a large enough opcache the entire PHP application (overtime) is loaded into memory.