Like all PHP programmers, three years ago I took up the creation of a personal freelance engine, everything was fine, until I decided to measure the page load time, and it was not small. The difficulty arose in the fact that modules that are added to the engine can also create personal controllers. The whole system was divided into 3 types of controllers: Системные , Пользовательские and Контроллеры модулей . I load controllers via Autoloader: \Controller\Main - the main page controller (user), for example, \System\Controller\Installer - system controller, for installing modules, it lies deep in the engine directories. A third type of controller can be \Module\$MODULE_NAME\Controller\Users and it is stored in Modules/$MODULE_NAME/Content . If you go through all the modules in the router through foreach and look for controllers in them - for too long. There should be a simpler and faster way, almost half a year already puzzling over my head, can you tell me something

  • 2
    Handwriting for yourself - approx. But for robots, this evil ... everyone suffers. And the lack of support by third-party developers is expanding ... and about your problem - use htaccess - the rules ... will immediately fly to the right controller of the desired module ... - Boris Runs
  • cache the configs of the modules. - Naumov
  • 1. Turn on the APC well, it turns the cache on. 2. Often, the slowest component of this routs can look there can be tightened. Well, that the rest advised. - E_p

1 answer 1

You are not alone in the squeaks. Many modern frameworks are faced with the problem that you described. Most often, this problem is solved by a cache. Controllers appear relatively rarely, and pages are requested very often. I propose to create an analog composer dump-autoload Each time after changing the project source code, run a script that will generate a file with a list of all controllers. And when a page is requested, load a ready list.