Source: Debian 12 / Ubuntu 22.04 使用源安装 LAMP 教程
本文將介紹使用官方來源和第三方來源在Debian 12 和Ubuntu 22.04 安裝最新版Apache 2 + PHP + MySQL 的教學課程,並且可以自行選擇PHP 版本。
Continue reading »Source: Debian 12 / Ubuntu 22.04 使用源安装 LAMP 教程
本文將介紹使用官方來源和第三方來源在Debian 12 和Ubuntu 22.04 安裝最新版Apache 2 + PHP + MySQL 的教學課程,並且可以自行選擇PHP 版本。
Continue reading »Source: Debian 12 編譯打包 PHP 7.4
Debian 12 已經移除 PHP 7.4 套件,只留 PHP 8.2 套件。 不幸的是,有些 PHP 程式還沒有升級到 PHP 8.2。 為了這些舊程式,我編譯打包了 php7.4-compat 套件。
Continue reading »Source: 在 Fly.io 上面跑 PHP
在 Heroku 把 free tier 拔的差不多後 (「Heroku 公佈了廢止免費方案的時間表」、「Heroku 的替代方案」),大家手上的小專案都往其他的服務跑,目前看起來做的比較有規模的就是 Fly.io 了,一個人可以建很多個 organization,而每個 organization 都有 free quota 可以用...
Continue reading »Source: PHP check whether property exists in object or class
I understand PHP does not have a pure object variable, but I want to check whether a property is in the given object or class.
Continue reading »Source: How to rename PHPSESSID?
See this link for PHP runtime configuration. The variable you are looking for is session.name. You can also alter this programmatically by calling session_name before any call to session_start or session_register.
session_name('mySessionName');
session_start();
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.
Source: Tutorial: Log to Console in PHP
function console_log($data, $add_script_tags = false) {
$command = 'console.log('. json_encode($data, JSON_HEX_TAG).');';
if ($add_script_tags) {
$command = '<script>'. $command . '</script>';
}
echo $command;
}
Continue reading »