• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Macbook-m1-Big-Sur-安装Valet-运行yii2

php 搞代码 3年前 (2022-02-28) 11次浏览 已收录 0个评论

筹备工作

假设你曾经在本机装置实现了 brew / composer / php

查看环境变量

<code class="bash">$echo $PATH | grep composer

#如果没有,增加环境变量
$export PATH=~/.composer/vendor/bin:$PATH
#检查一下
$echo $PATH | grep composer
/Users/yourname/.composer/vendor/bin:

全局装置Valet

<code class="bash">$composer global require laravel/valet
Changed current directory to /Users/yuanjian/.composer
Using version ^2.14 for laravel/valet
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 22 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-php80 (v1.22.1): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.22.1): Loading from cache
  - Installing symfony/polyfill-php72 (v1.22.1): Loading from cache
  - Installing symfony/var-dumper (v4.4.21): Downloading (100%)         
  - Installing tightenco/collect (v8.0.4): Downloading (100%)         
  - Installing nategood/httpful (0.2.20): Downloading (100%)         
  - Installing symfony/process (v4.4.20): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing php-di/invoker (2.0.0): Downloading (100%)         
  - Installing symfony/service-contracts (v1.1.9): Downloading (100%)         
  - Installing symfony/polyfill-php73 (v1.22.1): Loading from cache
  - Installing symfony/console (v4.4.21): Loading from cache
  - Installing mnapoli/silly (1.7.2): Downloading (100%)         
  - Installing psr/simple-cache (1.0.1): Loading from cache
  - Installing symfony/translation-contracts (v1.1.10): Downloading (100%)         
  - Installing symfony/translation (v4.4.21): Downloading (100%)         
  - Installing nesbot/carbon (2.46.0): Downloading (100%)         
  - Installing doctrine/inflector (1.3.1): Downloading (100%)         
  - Installing illuminate/contracts (v5.8.36): Downloading (100%)         
  - Installing illuminate/support (v5.8.36): Downloading (100%)         
  - Installing illuminate/container (v5.8.36): Downloading (100%)         
  - Installing laravel/valet (v2.14.1): Downloading (100%)         
symfony/service-contracts suggests installing symfony/service-implementation
symfony/console suggests installing symfony/event-dispatcher
symfony/console suggests installing symfony/lock
symfony/console suggests installing psr/log (For using the console logger)
symfony/translation suggests installing symfony/config
symfony/translation suggests installing symfony/yaml
illuminate/support suggests installing illuminate/filesystem (Required to use the composer class (5.8.*).)
illuminate/support suggests installing moontoast/math (Required to use ordered UUIDs (^1.1).)
illuminate/support suggests installing ramsey/uuid (Required to use Str::uuid() (^3.7).)
illuminate/support suggests installing vlucas/phpdotenv (Required to use the env helper (^3.3).)
Writing lock file
Generating autoload files
11 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Valet install

这将配置并装置 Valet 和 DnsMasq。此外,Valet 依赖的守护程序将配置为在系统启动时启动:

<code class="bash">$valet install
Stopping nginx...
Installing nginx...
[nginx] is not installed, installing it now via Brew... 🍻
Installing nginx configuration...
Installing nginx directory...
Updating PHP configuration...
Restarting [email protected]...
Installing dnsmasq...
[dnsmasq] is not installed, installing it now via Brew... 🍻
Updating Dnsmasq configuration...
Restarting dnsmasq...
Valet is configured to serve for TLD [.test]
Restarting nginx...

Valet installed successfully!

后果测试

测试DnsMasq

<code class="bash">$ping cc.test
PING cc.test (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.066 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.180 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.161 ms

park

切换到你本地的站点目录,例如我的目录是 ~/Sites

<code class="bash">$cd ~/Sites
$valet park

反对Yii2我的项目

下载驱动

因为 Valet 自身并不反对 Yii2,因而咱们须要本人写一个自定义驱动Laravel Valet 自定义站点驱动程序(learnku.com)。
当然,你也能够抉择github上现成的的chinaphp/yii2-valet-driver: Yii2 Valet Driver (github.com)。

<code class="bash">$cd ~/.config/valet/Drivers/
wget https://raw.githubusercontent.com/chinaphp/yii2-valet-driver/master/Yii2ValetDriver.php 

如果没有wget,能够应用brew install wget装置

链接Yii2站点目录

valet link yii2-name
http://yii2-name.test

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Macbook-m1-Big-Sur-安装Valet-运行yii2
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址