P粉5877801032023-08-07 14:30:09
On macOS, the ability to create Phar files may be disabled due to security concerns. Changing the phar.readonly value using ini_set will have no effect because it is a PHP_INI_SYSTEM type configuration, meaning it can only be set in the php.ini file, or using other configuration methods such as .htaccess (if you are using PHP as an Apache module) .
Since you mentioned that you don't want to install additional libraries or programs, there is still a way to create a Phar file without modifying system-wide settings or installing anything extra. You can temporarily override the phar.readonly setting using the -d option when running the php command. Here's how to do it:
php -d phar.readonly=0 /path/to/phar pack -f result.phar /Users/me/FolderToPack/