美文网首页
解决Windows使用phpstudy搭建laravel开发环境

解决Windows使用phpstudy搭建laravel开发环境

作者: liurongming | 来源:发表于2024-01-08 19:47 被阅读0次

问题一

出现以下错误时,使用:track_errors=Off

PS C:\Users\liurongming\Desktop\Local> php --version
Fatal error: Directive 'track_errors' is no longer available in PHP in Unknown on line 

在php.ini文件中,修改track_errors=Off


image.png
image.png

配置环境变量


image.png

此时使用,即可解决。

PS C:\Users\liurongming\Desktop\Local> php --version
PHP 8.2.9 (cli) (built: Aug  1 2023 12:41:16) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.2.9, Copyright (c) Zend Technologies
PS C:\Users\liurongming\Desktop\Local>

问题二

composer global require laravel/installer
In Factory.php line 648:

  The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl ex
  tension, you can disable this error, at your own risk, by setting the 'disable-tls' option to true.


require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>...]
PS C:\Users\liurongming\Desktop\Local> composer config -g --disable-tls true
The "--disable-tls" option does not exist.
config [-g|--global] [-e|--editor] [-a|--auth] [--unset] [-l|--list] [-f|--file FILE] [--absolute] [-j|--json] [-m|--merge] [--append] [--source] [--] [<setting-key> [<setting-value>...]]

PS C:\Users\liurongming\Desktop\Local>

修复:执行 composer config -g -- disable-tls true

PS C:\Users\liurongming\Desktop\Local> composer config -g -- disable-tls true
Warning: PHP Startup: Unable to load dynamic library 'openssl' (tried: 
You are now running Composer with SSL/TLS protection disabled.

再次执行出现以下错误

PS C:\Users\liurongming\Desktop\Local> composer create-project laravel/laravel example-app

Warning: PHP Startup: Unable to load dynamic library 'openssl' (tried: C:\php\ext\openssl (鎵句笉鍒版寚瀹氱殑妯″潡銆?, C:\php\ext\php_openssl.dll (鎵句笉鍒版寚瀹氱殑妯″潡銆?) in Unknown on line 0
You are running Composer with SSL/TLS protection disabled.
Creating a "laravel/laravel" project at "./example-app"

In ComposerRepository.php line 1155:

  You must enable the openssl extension in your php.ini to load information from https://repo.packagist.org


create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--ask] [--] [<package> [<directory> [<version>]]]

PS C:\Users\liurongming\Desktop\Local>
image.png

【直接解决看这里】最近解决方案,只要在php.ini中添加extension_dir=extextension=php_openssl.dllcomposer config -g -- disable-tls true 没有关系,因此再次执行composer config -g -- disable-tls false 修改回来即可。

image.png

配置国内源

所有项目都会使用该镜像地址:
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
取消配置:
composer config -g --unset repos.packagist

执行composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/完成后,通过命令composer config -g --list查看是否已经修改为阿里云的全镜像源。

PS C:\Users\liurongming\Desktop\Local> composer config -g --list
[repositories.packagist.org.type] composer
[repositories.packagist.org.url] https://mirrors.aliyun.com/composer/
[process-timeout] 300
[use-include-path] false
[use-parent-dir] prompt
[preferred-install] dist
[audit.abandoned] default
[notify-on-install] true
[github-protocols] [https, ssh]
[gitlab-protocol]
[vendor-dir] vendor (C:\Users\liurongming\Desktop\Local/vendor)
[bin-dir] {$vendor-dir}/bin (C:\Users\liurongming\Desktop\Local/vendor/bin)
[cache-dir] C:/Users/liurongming/AppData/Local/Composer
[data-dir] C:/Users/liurongming/AppData/Roaming/Composer
[cache-files-dir] {$cache-dir}/files (C:/Users/liurongming/AppData/Local/Composer/files)
[cache-repo-dir] {$cache-dir}/repo (C:/Users/liurongming/AppData/Local/Composer/repo)
[cache-vcs-dir] {$cache-dir}/vcs (C:/Users/liurongming/AppData/Local/Composer/vcs)
[cache-ttl] 15552000
[cache-files-ttl] 15552000
[cache-files-maxsize] 300MiB (314572800)
[cache-read-only] false
[bin-compat] auto
[discard-changes] false
[autoloader-suffix]
[sort-packages] false
[optimize-autoloader] false
[classmap-authoritative] false
[apcu-autoloader] false
[prepend-autoloader] true
[github-domains] [github.com]
[bitbucket-expose-hostname] true
[disable-tls] false
[secure-http] true
[cafile]
[capath]
[github-expose-hostname] true
[gitlab-domains] [gitlab.com]
[store-auths] prompt
[archive-format] tar
[archive-dir] .
[htaccess-protect] true
[use-github-api] true
[lock] true
[platform-check] php-only
[home] C:/Users/liurongming/AppData/Roaming/Composer

再次执行composer create-project laravel/laravel example-app缺少require ext-curl *

liurongming@DESKTOP-1G3LMHC MINGW64 ~/Desktop/Local
$ composer create-project laravel/laravel example-app
Creating a "laravel/laravel" project at "./example-app"
Installing laravel/laravel (v10.3.1)
  - Downloading laravel/laravel (v10.3.1)
  - Installing laravel/laravel (v10.3.1): Extracting archive
Created project in C:\Users\liurongming\Desktop\Local\example-app
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - spatie/laravel-ignition[2.0.0, ..., 2.3.3] require ext-curl * -> it is missing from your system. Install or enable PHP's curl extension.
    - Root composer.json requires spatie/laravel-ignition ^2.0 -> satisfiable by spatie/laravel-ignition[2.0.0, ..., 2.3.3].

To enable extensions, verify that they are enabled in your .ini files:
    - C:\phpstudy_pro\Extensions\php\php8.2.9nts\php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-curl` to temporarily ignore these required extensions.

liurongming@DESKTOP-1G3LMHC MINGW64 ~/Desktop/Local

查看的确缺少依赖包,那么接下来安装即可。

PS C:\Users\liurongming\Desktop\Local> php -m
[PHP Modules]
bcmath
calendar
Core
ctype
date
dom
filter
hash
iconv
json
libxml
mysqlnd
openssl
pcre
PDO
Phar
random
readline
Reflection
session
SimpleXML
SPL
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

PS C:\Users\liurongming\Desktop\Local>

解决以上问题,在php.ini再添加extension=curl即可。
再次执行,又出现以下问题。

PS C:\Users\liurongming\Desktop\Local> composer create-project laravel/laravel example-app
Creating a "laravel/laravel" project at "./example-app"
Installing laravel/laravel (v10.3.1)
  - Installing laravel/laravel (v10.3.1): Extracting archive
Created project in C:\Users\liurongming\Desktop\Local\example-app
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/framework[v10.10.0, ..., v10.38.2] require league/flysystem ^3.8.0 -> satisfiable by league/flysystem[3.8.0, ..., 3.22.0].
    - league/flysystem[3.3.0, ..., 3.14.0] require league/mime-type-detection ^1.0.0 -> satisfiable by league/mime-type-detection[1.0.0, ..., 1.13.0].
    - league/flysystem[3.15.0, ..., 3.22.0] require league/flysystem-local ^3.0.0 -> satisfiable by league/flysystem-local[3.15.0, ..., 3.23.0].
    - league/mime-type-detection[1.0.0, ..., 1.3.0] require php ^7.2 -> your php version (8.2.9) does not satisfy that requirement.
    - league/mime-type-detection[1.4.0, ..., 1.13.0] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
    - league/flysystem-local[3.15.0, ..., 3.23.0] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
    - Root composer.json requires laravel/framework ^10.10 -> satisfiable by laravel/framework[v10.10.0, ..., v10.38.2].

To enable extensions, verify that they are enabled in your .ini files:
    - C:\phpstudy_pro\Extensions\php\php8.2.9nts\php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-fileinfo` to temporarily ignore these required extensions.

执行composer时添加--ignore-platform-req=ext-fileinfo忽略版本不一致问题。

PS C:\Users\liurongming\Desktop\Local> composer create-project laravel/laravel example-app --ignore-platform-req=ext-fileinfo
Creating a "laravel/laravel" project at "./example-app"
Installing laravel/laravel (v10.3.1)
  - Installing laravel/laravel (v10.3.1): Extracting archive
Created project in C:\Users\liurongming\Desktop\Local\example-app
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 111 installs, 0 updates, 0 removals
  - Locking brick/math (0.11.0)
  - Locking carbonphp/carbon-doctrine-types (2.1.0)
  - Locking dflydev/dot-access-data (v3.0.2)
  - Locking doctrine/inflector (2.0.8)
  - Locking doctrine/lexer (3.0.0)
  - Locking dragonmantank/cron-expression (v3.3.3)
  - Locking egulias/email-validator (4.0.1)
  - Locking fakerphp/faker (v1.23.0)
  - Locking filp/whoops (2.15.4)
  - Locking fruitcake/php-cors (v1.2.0)
  - Locking graham-campbell/result-type (v1.1.2)
  - Locking guzzlehttp/guzzle (7.8.1)
  - Locking guzzlehttp/promises (2.0.1)
  - Locking guzzlehttp/psr7 (2.6.2)
  - Locking guzzlehttp/uri-template (v1.0.2)
  - Locking hamcrest/hamcrest-php (v2.0.1)
  - Locking laravel/framework (v10.38.2)
  - Locking laravel/pint (v1.13.6)
  - Locking laravel/prompts (v0.1.13)
  - Locking laravel/sail (v1.26.3)
  - Locking laravel/sanctum (v3.3.2)
  - Locking laravel/serializable-closure (v1.3.3)
  - Locking laravel/tinker (v2.8.2)
  - Locking league/commonmark (2.4.1)
  - Locking league/config (v1.2.0)
  - Locking league/flysystem (3.22.0)
  - Locking league/flysystem-local (3.23.0)
  - Locking league/mime-type-detection (1.13.0)
  - Locking mockery/mockery (1.6.6)
  - Locking monolog/monolog (3.5.0)
  - Locking myclabs/deep-copy (1.11.1)
  - Locking nesbot/carbon (2.72.1)
  - Locking nette/schema (v1.2.5)
  - Locking nette/utils (v4.0.2)
  - Locking nikic/php-parser (v4.18.0)
  - Locking nunomaduro/collision (v7.10.0)
  - Locking nunomaduro/termwind (v1.15.1)
  - Locking phar-io/manifest (2.0.3)
  - Locking phar-io/version (3.2.1)
  - Locking phpoption/phpoption (1.9.2)
  - Locking phpunit/php-code-coverage (10.1.11)
  - Locking phpunit/php-file-iterator (4.1.0)
  - Locking phpunit/php-invoker (4.0.0)
  - Locking phpunit/php-text-template (3.0.1)
  - Locking phpunit/php-timer (6.0.0)
  - Locking phpunit/phpunit (10.5.5)
  - Locking psr/clock (1.0.0)
  - Locking psr/container (2.0.2)
  - Locking psr/event-dispatcher (1.0.0)
  - Locking psr/http-client (1.0.3)
  - Locking psr/http-factory (1.0.2)
  - Locking psr/http-message (2.0)
  - Locking psr/log (3.0.0)
  - Locking psr/simple-cache (3.0.0)
  - Locking psy/psysh (v0.11.22)
  - Locking ralouphie/getallheaders (3.0.3)
  - Locking ramsey/collection (2.0.0)
  - Locking ramsey/uuid (4.7.5)
  - Locking sebastian/cli-parser (2.0.0)
  - Locking sebastian/code-unit (2.0.0)
  - Locking sebastian/code-unit-reverse-lookup (3.0.0)
  - Locking sebastian/comparator (5.0.1)
  - Locking sebastian/complexity (3.2.0)
  - Locking sebastian/diff (5.0.3)
  - Locking sebastian/environment (6.0.1)
  - Locking sebastian/exporter (5.1.1)
  - Locking sebastian/global-state (6.0.1)
  - Locking sebastian/lines-of-code (2.0.2)
  - Locking sebastian/object-enumerator (5.0.0)
  - Locking sebastian/object-reflector (3.0.0)
  - Locking sebastian/recursion-context (5.0.0)
  - Locking sebastian/type (4.0.0)
  - Locking sebastian/version (4.0.1)
  - Locking spatie/backtrace (1.5.3)
  - Locking spatie/flare-client-php (1.4.3)
  - Locking spatie/ignition (1.12.0)
  - Locking spatie/laravel-ignition (2.3.3)
  - Locking symfony/console (v6.4.2)
  - Locking symfony/css-selector (v7.0.0)
  - Locking symfony/deprecation-contracts (v3.3.0)
  - Locking symfony/error-handler (v6.4.0)
  - Locking symfony/event-dispatcher (v7.0.0)
  - Locking symfony/event-dispatcher-contracts (v3.4.0)
  - Locking symfony/finder (v6.4.0)
  - Locking symfony/http-foundation (v6.4.2)
  - Locking symfony/http-kernel (v6.4.2)
  - Locking symfony/mailer (v6.4.2)
  - Locking symfony/mime (v6.4.0)
  - Locking symfony/polyfill-ctype (v1.28.0)
  - Locking symfony/polyfill-intl-grapheme (v1.28.0)
  - Locking symfony/polyfill-intl-idn (v1.28.0)
  - Locking symfony/polyfill-intl-normalizer (v1.28.0)
  - Locking symfony/polyfill-mbstring (v1.28.0)
  - Locking symfony/polyfill-php72 (v1.28.0)
  - Locking symfony/polyfill-php80 (v1.28.0)
  - Locking symfony/polyfill-php83 (v1.28.0)
  - Locking symfony/polyfill-uuid (v1.28.0)
  - Locking symfony/process (v6.4.2)
  - Locking symfony/routing (v6.4.2)
  - Locking symfony/service-contracts (v3.4.0)
  - Locking symfony/string (v7.0.2)
  - Locking symfony/translation (v6.4.2)
  - Locking symfony/translation-contracts (v3.4.1)
  - Locking symfony/uid (v6.4.0)
  - Locking symfony/var-dumper (v6.4.2)
  - Locking symfony/yaml (v6.4.0)
  - Locking theseer/tokenizer (1.2.1)
  - Locking tijsverkoyen/css-to-inline-styles (v2.2.7)
  - Locking vlucas/phpdotenv (v5.5.0)
  - Locking voku/portable-ascii (2.0.1)
  - Locking webmozart/assert (1.11.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 111 installs, 0 updates, 0 removals
  - Downloading doctrine/inflector (2.0.8)
  - Downloading doctrine/lexer (3.0.0)
  - Downloading symfony/polyfill-ctype (v1.28.0)
  - Downloading webmozart/assert (1.11.0)
  - Downloading dragonmantank/cron-expression (v3.3.3)
  - Downloading symfony/deprecation-contracts (v3.3.0)
  - Downloading psr/container (2.0.2)
  - Downloading fakerphp/faker (v1.23.0)
  - Downloading symfony/polyfill-php80 (v1.28.0)
  - Downloading symfony/polyfill-php83 (v1.28.0)
  - Downloading symfony/polyfill-mbstring (v1.28.0)
  - Downloading symfony/http-foundation (v6.4.2)
  - Downloading fruitcake/php-cors (v1.2.0)
  - Downloading psr/http-message (2.0)
  - Downloading psr/http-client (1.0.3)
  - Downloading ralouphie/getallheaders (3.0.3)
  - Downloading psr/http-factory (1.0.2)
  - Downloading guzzlehttp/psr7 (2.6.2)
  - Downloading guzzlehttp/promises (2.0.1)
  - Downloading guzzlehttp/guzzle (7.8.1)
  - Downloading guzzlehttp/uri-template (v1.0.2)
  - Downloading laravel/pint (v1.13.6)
  - Downloading symfony/polyfill-intl-normalizer (v1.28.0)
  - Downloading symfony/polyfill-intl-grapheme (v1.28.0)
  - Downloading symfony/string (v7.0.2)
  - Downloading symfony/service-contracts (v3.4.0)
  - Downloading symfony/console (v6.4.2)
  - Downloading voku/portable-ascii (2.0.1)
  - Downloading phpoption/phpoption (1.9.2)
  - Downloading graham-campbell/result-type (v1.1.2)
  - Downloading vlucas/phpdotenv (v5.5.0)
  - Downloading symfony/css-selector (v7.0.0)
  - Downloading tijsverkoyen/css-to-inline-styles (v2.2.7)
  - Downloading symfony/var-dumper (v6.4.2)
  - Downloading symfony/polyfill-uuid (v1.28.0)
  - Downloading symfony/uid (v6.4.0)
  - Downloading symfony/routing (v6.4.2)
  - Downloading symfony/process (v6.4.2)
  - Downloading symfony/polyfill-php72 (v1.28.0)
  - Downloading symfony/polyfill-intl-idn (v1.28.0)
  - Downloading symfony/mime (v6.4.0)
  - Downloading psr/event-dispatcher (1.0.0)
  - Downloading symfony/event-dispatcher-contracts (v3.4.0)
  - Downloading symfony/event-dispatcher (v7.0.0)
  - Downloading psr/log (3.0.0)
  - Downloading egulias/email-validator (4.0.1)
  - Downloading symfony/mailer (v6.4.2)
  - Downloading symfony/error-handler (v6.4.0)
  - Downloading symfony/http-kernel (v6.4.2)
  - Downloading symfony/finder (v6.4.0)
  - Downloading ramsey/collection (2.0.0)
  - Downloading brick/math (0.11.0)
  - Downloading ramsey/uuid (4.7.5)
  - Downloading psr/simple-cache (3.0.0)
  - Downloading nunomaduro/termwind (v1.15.1)
  - Downloading symfony/translation-contracts (v3.4.1)
  - Downloading symfony/translation (v6.4.2)
  - Downloading psr/clock (1.0.0)
  - Downloading carbonphp/carbon-doctrine-types (2.1.0)
  - Downloading nesbot/carbon (2.72.1)
  - Downloading monolog/monolog (3.5.0)
  - Downloading league/mime-type-detection (1.13.0)
  - Downloading league/flysystem (3.22.0)
  - Downloading league/flysystem-local (3.23.0)
  - Downloading nette/utils (v4.0.2)
  - Downloading nette/schema (v1.2.5)
  - Downloading dflydev/dot-access-data (v3.0.2)
  - Downloading league/config (v1.2.0)
  - Downloading league/commonmark (2.4.1)
  - Downloading laravel/serializable-closure (v1.3.3)
  - Downloading laravel/prompts (v0.1.13)
  - Downloading laravel/framework (v10.38.2)
  - Downloading symfony/yaml (v6.4.0)
  - Downloading laravel/sail (v1.26.3)
  - Downloading laravel/sanctum (v3.3.2)
  - Downloading nikic/php-parser (v4.18.0)
  - Downloading psy/psysh (v0.11.22)
  - Downloading laravel/tinker (v2.8.2)
  - Downloading hamcrest/hamcrest-php (v2.0.1)
  - Downloading mockery/mockery (1.6.6)
  - Downloading filp/whoops (2.15.4)
  - Downloading nunomaduro/collision (v7.10.0)
  - Downloading sebastian/version (4.0.1)
  - Downloading sebastian/type (4.0.0)
  - Downloading sebastian/recursion-context (5.0.0)
  - Downloading sebastian/object-reflector (3.0.0)
  - Downloading sebastian/object-enumerator (5.0.0)
  - Downloading sebastian/global-state (6.0.1)
  - Downloading sebastian/exporter (5.1.1)
  - Downloading sebastian/environment (6.0.1)
  - Downloading sebastian/diff (5.0.3)
  - Downloading sebastian/comparator (5.0.1)
  - Downloading sebastian/code-unit (2.0.0)
  - Downloading sebastian/cli-parser (2.0.0)
  - Downloading phpunit/php-timer (6.0.0)
  - Downloading phpunit/php-text-template (3.0.1)
  - Downloading phpunit/php-invoker (4.0.0)
  - Downloading phpunit/php-file-iterator (4.1.0)
  - Downloading theseer/tokenizer (1.2.1)
  - Downloading sebastian/lines-of-code (2.0.2)
  - Downloading sebastian/complexity (3.2.0)
  - Downloading sebastian/code-unit-reverse-lookup (3.0.0)
  - Downloading phpunit/php-code-coverage (10.1.11)
  - Downloading phar-io/version (3.2.1)
  - Downloading phar-io/manifest (2.0.3)
  - Downloading myclabs/deep-copy (1.11.1)
  - Downloading phpunit/phpunit (10.5.5)
  - Downloading spatie/backtrace (1.5.3)
  - Downloading spatie/flare-client-php (1.4.3)
  - Downloading spatie/ignition (1.12.0)
  - Downloading spatie/laravel-ignition (2.3.3)
  - Installing doctrine/inflector (2.0.8): Extracting archive
  - Installing doctrine/lexer (3.0.0): Extracting archive
  - Installing symfony/polyfill-ctype (v1.28.0): Extracting archive
  - Installing webmozart/assert (1.11.0): Extracting archive
  - Installing dragonmantank/cron-expression (v3.3.3): Extracting archive
  - Installing symfony/deprecation-contracts (v3.3.0): Extracting archive
  - Installing psr/container (2.0.2): Extracting archive
  - Installing fakerphp/faker (v1.23.0): Extracting archive
  - Installing symfony/polyfill-php80 (v1.28.0): Extracting archive
  - Installing symfony/polyfill-php83 (v1.28.0): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.28.0): Extracting archive
  - Installing symfony/http-foundation (v6.4.2): Extracting archive
  - Installing fruitcake/php-cors (v1.2.0): Extracting archive
  - Installing psr/http-message (2.0): Extracting archive
  - Installing psr/http-client (1.0.3): Extracting archive
  - Installing ralouphie/getallheaders (3.0.3): Extracting archive
  - Installing psr/http-factory (1.0.2): Extracting archive
  - Installing guzzlehttp/psr7 (2.6.2): Extracting archive
  - Installing guzzlehttp/promises (2.0.1): Extracting archive
  - Installing guzzlehttp/guzzle (7.8.1): Extracting archive
  - Installing guzzlehttp/uri-template (v1.0.2): Extracting archive
  - Installing laravel/pint (v1.13.6): Extracting archive
  - Installing symfony/polyfill-intl-normalizer (v1.28.0): Extracting archive
  - Installing symfony/polyfill-intl-grapheme (v1.28.0): Extracting archive
  - Installing symfony/string (v7.0.2): Extracting archive
  - Installing symfony/service-contracts (v3.4.0): Extracting archive
  - Installing symfony/console (v6.4.2): Extracting archive
  - Installing voku/portable-ascii (2.0.1): Extracting archive
  - Installing phpoption/phpoption (1.9.2): Extracting archive
  - Installing graham-campbell/result-type (v1.1.2): Extracting archive
  - Installing vlucas/phpdotenv (v5.5.0): Extracting archive
  - Installing symfony/css-selector (v7.0.0): Extracting archive
  - Installing tijsverkoyen/css-to-inline-styles (v2.2.7): Extracting archive
  - Installing symfony/var-dumper (v6.4.2): Extracting archive
  - Installing symfony/polyfill-uuid (v1.28.0): Extracting archive
  - Installing symfony/uid (v6.4.0): Extracting archive
  - Installing symfony/routing (v6.4.2): Extracting archive
  - Installing symfony/process (v6.4.2): Extracting archive
  - Installing symfony/polyfill-php72 (v1.28.0): Extracting archive
  - Installing symfony/polyfill-intl-idn (v1.28.0): Extracting archive
  - Installing symfony/mime (v6.4.0): Extracting archive
  - Installing psr/event-dispatcher (1.0.0): Extracting archive
  - Installing symfony/event-dispatcher-contracts (v3.4.0): Extracting archive
  - Installing symfony/event-dispatcher (v7.0.0): Extracting archive
  - Installing psr/log (3.0.0): Extracting archive
  - Installing egulias/email-validator (4.0.1): Extracting archive
  - Installing symfony/mailer (v6.4.2): Extracting archive
  - Installing symfony/error-handler (v6.4.0): Extracting archive
  - Installing symfony/http-kernel (v6.4.2): Extracting archive
  - Installing symfony/finder (v6.4.0): Extracting archive
  - Installing ramsey/collection (2.0.0): Extracting archive
  - Installing brick/math (0.11.0): Extracting archive
  - Installing ramsey/uuid (4.7.5): Extracting archive
  - Installing psr/simple-cache (3.0.0): Extracting archive
  - Installing nunomaduro/termwind (v1.15.1): Extracting archive
  - Installing symfony/translation-contracts (v3.4.1): Extracting archive
  - Installing symfony/translation (v6.4.2): Extracting archive
  - Installing psr/clock (1.0.0): Extracting archive
  - Installing carbonphp/carbon-doctrine-types (2.1.0): Extracting archive
  - Installing nesbot/carbon (2.72.1): Extracting archive
  - Installing monolog/monolog (3.5.0): Extracting archive
  - Installing league/mime-type-detection (1.13.0): Extracting archive
  - Installing league/flysystem (3.22.0): Extracting archive
  - Installing league/flysystem-local (3.23.0): Extracting archive
  - Installing nette/utils (v4.0.2): Extracting archive
  - Installing nette/schema (v1.2.5): Extracting archive
  - Installing dflydev/dot-access-data (v3.0.2): Extracting archive
  - Installing league/config (v1.2.0): Extracting archive
  - Installing league/commonmark (2.4.1): Extracting archive
  - Installing laravel/serializable-closure (v1.3.3): Extracting archive
  - Installing laravel/prompts (v0.1.13): Extracting archive
  - Installing laravel/framework (v10.38.2): Extracting archive
  - Installing symfony/yaml (v6.4.0): Extracting archive
  - Installing laravel/sail (v1.26.3): Extracting archive
  - Installing laravel/sanctum (v3.3.2): Extracting archive
  - Installing nikic/php-parser (v4.18.0): Extracting archive
  - Installing psy/psysh (v0.11.22): Extracting archive
  - Installing laravel/tinker (v2.8.2): Extracting archive
  - Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive
  - Installing mockery/mockery (1.6.6): Extracting archive
  - Installing filp/whoops (2.15.4): Extracting archive
  - Installing nunomaduro/collision (v7.10.0): Extracting archive
  - Installing sebastian/version (4.0.1): Extracting archive
  - Installing sebastian/type (4.0.0): Extracting archive
  - Installing sebastian/recursion-context (5.0.0): Extracting archive
  - Installing sebastian/object-reflector (3.0.0): Extracting archive
  - Installing sebastian/object-enumerator (5.0.0): Extracting archive
  - Installing sebastian/global-state (6.0.1): Extracting archive
  - Installing sebastian/exporter (5.1.1): Extracting archive
  - Installing sebastian/environment (6.0.1): Extracting archive
  - Installing sebastian/diff (5.0.3): Extracting archive
  - Installing sebastian/comparator (5.0.1): Extracting archive
  - Installing sebastian/code-unit (2.0.0): Extracting archive
  - Installing sebastian/cli-parser (2.0.0): Extracting archive
  - Installing phpunit/php-timer (6.0.0): Extracting archive
  - Installing phpunit/php-text-template (3.0.1): Extracting archive
  - Installing phpunit/php-invoker (4.0.0): Extracting archive
  - Installing phpunit/php-file-iterator (4.1.0): Extracting archive
  - Installing theseer/tokenizer (1.2.1): Extracting archive
  - Installing sebastian/lines-of-code (2.0.2): Extracting archive
  - Installing sebastian/complexity (3.2.0): Extracting archive
  - Installing sebastian/code-unit-reverse-lookup (3.0.0): Extracting archive
  - Installing phpunit/php-code-coverage (10.1.11): Extracting archive
  - Installing phar-io/version (3.2.1): Extracting archive
  - Installing phar-io/manifest (2.0.3): Extracting archive
  - Installing myclabs/deep-copy (1.11.1): Extracting archive
  - Installing phpunit/phpunit (10.5.5): Extracting archive
  - Installing spatie/backtrace (1.5.3): Extracting archive
  - Installing spatie/flare-client-php (1.4.3): Extracting archive
  - Installing spatie/ignition (1.12.0): Extracting archive
  - Installing spatie/laravel-ignition (2.3.3): Extracting archive
64 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   INFO  Discovering packages.

  laravel/sail .................................................................................................. DONE
  laravel/sanctum ............................................................................................... DONE
  laravel/tinker ................................................................................................ DONE
  nesbot/carbon ................................................................................................. DONE
  nunomaduro/collision .......................................................................................... DONE
  nunomaduro/termwind ........................................................................................... DONE
  spatie/laravel-ignition ....................................................................................... DONE

83 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force

   INFO  No publishable resources for tag [laravel-assets].

No security vulnerability advisories found.
> @php artisan key:generate --ansi

   INFO  Application key set successfully.

PS C:\Users\liurongming\Desktop\Local>

最终修改配置文件为:


image.png

主要修改地方

track_errors=Off
extension_dir=ext
extension=php_openssl.dll
extension=zip
extension=curl

安装完成时,依然出现问题。

PS C:\Users\liurongming\Desktop\Local\example-app> php artisan serve

   WARN  Failed to listen on 127.0.0.1:8000 (reason: ?).

   WARN  Failed to listen on 127.0.0.1:8001 (reason: ?).

   WARN  Failed to listen on 127.0.0.1:8002 (reason: ?).

   WARN  Failed to listen on 127.0.0.1:8003 (reason: ?).

   WARN  Failed to listen on 127.0.0.1:8004 (reason: ?).

   WARN  Failed to listen on 127.0.0.1:8005 (reason: ?).

   WARN  Failed to listen on 127.0.0.1:8006 (reason: ?).

   WARN  Failed to listen on 127.0.0.1:8007 (reason: ?).

   WARN  Failed to listen on 127.0.0.1:8008 (reason: ?).

   WARN  Failed to listen on 127.0.0.1:8009 (reason: ?).

   WARN  Failed to listen on 127.0.0.1:8010 (reason: ?).

解决:在php.ini添加variables_order = "GPCS",最终完整配置如下。

[Date]
date.timezone=Asia/Shanghai
[PHP]
max_execution_time = 300
max_input_time=60
max_input_vars=3000
memory_limit=256M
upload_max_filesize = 100M
post_max_size = 100M
max_file_uploads = 100
display_errors = On
display_startup_errors=On
log_errors=On
track_errors=Off
html_errors=On
error_log=C:/phpstudy_pro/Extensions/php/php8.2.9nts.log
error_reporting=E_ALL & ~E_NOTICE
allow_url_fopen=On
allow_url_include=Off
extension_dir=ext
extension=php_openssl.dll
extension=zip
extension=curl
variables_order = "GPCS"

再次运行,成功监听并运行 。

PS C:\Users\liurongming\Desktop\Local\example-app> php artisan serve

   INFO  Server running on [http://127.0.0.1:8000].

  Press Ctrl+C to stop the server

image.png

使用phpstudy调试结果。


image.png

至此,环境搭建完成。【建议用Mac系统开发,配置非常简单。或者windows采用WSL2

相关文章

网友评论

      本文标题:解决Windows使用phpstudy搭建laravel开发环境

      本文链接:https://www.haomeiwen.com/subject/nyfondtx.html