?首先參考:Composer三步曲:安裝、使用、發布
在 php 路徑下,應能打開命令行輸入php -v
能夠看到php版本信息。
然后執行以下三條:
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"php composer-setup.phpphp -r "unlink('composer-setup.php');"
這時遇到報錯:
Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?
參考:https://www.cnblogs.com/ec04/p/12390050.html
1.windows下的PHP,只需要到php.ini中把extension=php_openssl.dll前面的;刪掉,重啟服務就可以了。
經查,我的 php 沒有這一項,添加,然后 iisreset 。再次執行以上三條,通過,下載安裝成功。
All settings correct for using Composer
Downloading...
Composer (version 2.7.7) successfully installed to: C:\php\composer.phar
Use it: php composer.phar
C:\php>php comoser.phar
Could not open input file: comoser.phar
C:\php>php composer.phar
? ?______
? / ____/___ ?____ ___ ?____ ?____ ?________ ?_____
?/ / ? / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ?) ?__/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
? ? ? ? ? ? ? ? ? ? /_/
Composer version 2.7.7 2024-06-10 22:11:12
?
最后參考:php使用wkhtmltopdf html轉為ptf或圖片_php wkhtmlto-CSDN博客
執行:composer require mikehaertl/phpwkhtmltopdf
這時有問題,需要改為:php composer.phar require mikehaertl/phpwkhtmltopdf
執行通過:
./composer.json has been created
Running composer update mikehaertl/phpwkhtmltopdf
Loading composer repositories with package information
Updating dependencies
Lock file operations: 3 installs, 0 updates, 0 removals
? - Locking mikehaertl/php-shellcommand (1.7.0)
? - Locking mikehaertl/php-tmpfile (1.2.1)
? - Locking mikehaertl/phpwkhtmltopdf (2.5.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
? - Downloading mikehaertl/php-tmpfile (1.2.1)
? - Downloading mikehaertl/php-shellcommand (1.7.0)
? - Downloading mikehaertl/phpwkhtmltopdf (2.5.0)
?0/3 [>---------------------------] ? 0%
?2/3 [==================>---------] ?66%
?3/3 [============================] 100%
? - Installing mikehaertl/php-tmpfile (1.2.1): Extracting archive
? - Installing mikehaertl/php-shellcommand (1.7.0): Extracting archive
? - Installing mikehaertl/phpwkhtmltopdf (2.5.0): Extracting archive
?0/3 [>---------------------------] ? 0%
?3/3 [============================] 100%
Generating autoload files
No security vulnerability advisories found.
Using version ^2.5 for mikehaertl/phpwkhtmltopdf?