5 月 262023
 

Source: 在 Fly.io 上面跑 PHP

在 Heroku 把 free tier 拔的差不多後 (「Heroku 公佈了廢止免費方案的時間表」、「Heroku 的替代方案」),大家手上的小專案都往其他的服務跑,目前看起來做的比較有規模的就是 Fly.io 了,一個人可以建很多個 organization,而每個 organization 都有 free quota 可以用...

Continue reading »
4 月 122021
 

Source: symfony doc performance

By default, the Symfony Standard Edition uses Composer’s autoloader in the autoload.php file. This autoloader is easy to use, as it will automatically find any new classes that you’ve placed in the registered directories.

Unfortunately, this comes at a cost, as the loader iterates over all configured namespaces to find a particular file, making file_exists() calls until it finally finds the file it’s looking for.

The simplest solution is to tell Composer to build an optimized “class map”, which is a big array of the locations of all the classes and it’s stored in vendor/composer/autoload_classmap.php.

The class map can be generated from the command line, and might become part of your deploy process:

composer dump-autoload --optimize --no-dev --classmap-authoritative

--optimize: Dumps every PSR-0 and PSR-4 compatible class used in your application.

--no-dev: Excludes the classes that are only needed in the development environment (e.g. tests).

--classmap-authoritative: Prevents Composer from scanning the file system for classes that are not found in the class map.