Practice of LaravelValet in Mac minimal development environment-php Tutorial

Source: Internet
Author: User
LaravelValet is a simple Mac development environment. MacThe following simple development environment not only supports local development, but also shared access to the public network. after your computer is started on, Caddy will be started in the background, and Valet will use DnsMasq to write all the files. the dev domain name points to the website you have installed locally, such as the blog in the directory where the site is located, and you can access the blog through a browser. dev will automatically access the blog. Sharing to the public network actually relies mainly on ngrok.

Install
  • UpdateHomebrew
brew update  
  • Ensure brew services are available
brew services list  
  • InstallPhp70If not
brew install php70  
  • Ensure ~ /. Composer/vendor/bin has been added to the system PATH Directory.
  • InstallValet
composer global require laravel/valet  
  • InstallValetAndDnsMasq
valet install  

If the following error occurs in the previous step:

[ReflectionException]  Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist

This is because the Composer \ Repository \ ComposerRepository: whatProvides API is updated. you have installed fxp/composer-asset-plugin globally, so you need to update it:

composer global require fxp/composer-asset-plugin --no-plugins  

IfDnsMasqIf installation fails, install it manually.

brew install dnsmasq  
  • Ping *. dev. if the Ping succeeds, it will be OK.
⇒  ping *.devPING *.dev (127.0.0.1): 56 data bytes  64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.040 ms  64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.065 ms  64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.064 ms  64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.062 ms  
Start a Valet site

Currently, drivers supported by version 1.1.7 are as follows:

  • Laravel
  • Lumen
  • Symfony
  • Zend
  • CakePHP 3
  • WordPress
  • Bedrock
  • Craft
  • Statamic
  • Jigsaw
  • Wordpress
  • Joomla
  • Contal
  • Sculpin
  • Static HTML
Of course, you can also drive it yourself, Custom Valet Drivers
  • Create a folder
mkdir ~/WebRoot/ValetSite && cd ~/WebRoot/ValetSite  
  • RunParkCommand to use the directory above as the site path
valet park  
  • Create a Laravel-driven site
laravel new blog  
  • Browser access http://blog.dev is OK
Link command

The link command can also be used to start the Laravel site. The park command treats all the folders in this directory as independent sites. when you only need to start one site, you can use the link command.

cd ~/WebRoot/ValetSite/blog  valet link test-blog  

Execute the above command to access the project site through http://test-blog.dev, there are two useful commands:

valet links  valet unlink  

I can see why it is used.

Make the site support TLS

It is also easy to make the site support TLS, and you need to execute the following:

valet secure blog  

In this way you can use the https://blog.dev for access, cancel the words:

valet unsecure blog  
Sharing site

This requirement is actually quite practical. for example, if something you develop needs to be accessed by others through the Internet, you only need a simple command.

valet share  

In this way, an Internet URL is generated through ngrok. to stop sharing, you can click Control + C to cancel the process.

ngrok by @inconshreveable                                                                                                                                                 (Ctrl+C to quit)Tunnel Status                 online  Version                       2.0.25/2.1.1  Region                        United States (us)  Web Interface                 http://127.0.0.1:4040  Forwarding                    http://fda651a8.ngrok.io -> blog.dev:80  Forwarding                    https://fda651a8.ngrok.io -> blog.dev:80Connections                   ttl     opn     rt1     rt5     p50     p90                                0       0       0.00    0.00    0.00    0.00
View site logs

If you want to view the logs of all sites, the new logs will be automatically displayed on the terminal and you only need to execute valet logs

There is also a hidden console: access http: // localhost: 4040/inspect/http

There are also some Valet commands
Command Description

Valet forget

Run this command in the "parked" directory to delete it from the parded directory list.

Valet paths

View all "parked" paths

Valet restart

Restart the Valet program

Valet start

Start the Valet program

Valet stop

Stop the Valet program

Valet uninstall

Uninstall Valet program

Reprinted please note: Reprinted from Ryan is a Cainiao | LNMP technology stack notes

If you think this article is very helpful to you, why not give it a try?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.