亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
Install and Configure Homebrew
Set Up Laravel Valet for Local Development
Enhance Your Setup with Useful Tools
Bonus: Custom Domains and SSL
Final Tips for a Smooth Workflow
Home Backend Development PHP Tutorial Optimizing the PHP Development Experience on macOS with Homebrew and Valet

Optimizing the PHP Development Experience on macOS with Homebrew and Valet

Jul 28, 2025 am 04:39 AM
PHP Installation

First install and configure Homebrew, install it through the /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" command, then update the shell configuration file to ensure brew is in PATH, then execute echo 'eval "$(/opt/homebrew/bin/brew shellenv)" >> ~/.zprofile and run eval "$(/opt/homebrew/bin/brew shellenv)", then add the PHP repository brew tap shivammathur/php and brew tap homebrew/services, install the specified PHP version such as brew install Shivammathur/php/php@8.3 and link brew link php@8.3. If necessary, add the PHP path to ~/.zshrc and refresh the configuration. Finally, verify through php -v; then set Laravel Valet, first install Composer, brew install composer, then install Valet globally, composer global require laravel/valet, ensure ~/.composer/vendor/bin is in PATH, then run valet install initialization environment, use valet park to set the project directory such as ~/Sites as an accessible path, or use valet link to create links for a single project to achieve http://project name.test access; to further enhance the environment, brew install mysql and brew services start MySQL runs MySQL, or select MariaDB, and install Redis, execute brew install redis and brew services start redis, add PHP extensions through brew install php@8.3-redis and run valet restart restart restart service. To enable Xdebug, you need to execute valet use php@8.3 --with-extension=xdebug and configure listening port 9003 in the IDE. Optional operations include running valet install --with-trusted-ca trust root certificate, using valet domain .local to replace the default domain name, and enabling HTTPS for the site through valet secure project-name. It is recommended to regularly brew upgrade for daily maintenance. php@8.3 updates PHP, executes valet restart after major changes, uses valet which checks the route, and valet forgets to unlink the project, and ultimately implements a lightweight, efficient local PHP development environment without Docker or Vagrant.

Optimizing the PHP Development Experience on macOS with Homebrew and Valet

Setting up a smooth PHP development environment on macOS used to be a headache—managing Apache, PHP versions, MySQL, and virtual hosts manually was time-consuming and error-prone. Thanks to Homebrew and Laravel Valet , developers can now get a lightweight, fast, and reliable local PHP stack up and running in minutes. Here's how to optimize your PHP development workflow on macOS using These tools.

Optimizing the PHP Development Experience on macOS with Homebrew and Valet

Install and Configure Homebrew

Homebrew is the missing package manager for macOS, and it's the foundation of a clean, maintainedable dev setup.

  1. Install Homebrew (if you haven't already):
 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Update your shell profile to ensure brew is in your PATH (especially on Apple Silicon Macs):
 echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
  1. Tap the PHP and other useful repositories :
 brew tap shivammathur/php
brew tap homebrew/services
  1. Install PHP (choose your preferred version, eg, 8.3):
 brew install shivammathur/php/php@8.3
  1. Link the PHP version so it's available globally:
 brew link php@8.3

Optional: Add PHP to your shell profile if it's not in PATH automatically:

Optimizing the PHP Development Experience on macOS with Homebrew and Valet
 echo 'export PATH="/opt/homebrew/opt/php@8.3/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
  1. Verify installation :
 php -v

You now have a modern PHP version managed cleanly via Homebrew.


Set Up Laravel Valet for Local Development

Valet is a minimalistic, Laravel-built development environment that uses Nginx and dnsmasq under the hood. It's fast, uses minimum resources, and supports .test (or custom) domains automatically.

Optimizing the PHP Development Experience on macOS with Homebrew and Valet
  1. Install Valet via Composer :

Make sure Composer is installed:

 brew install composer

Then install Valet globally:

 composer global requires laravel/valet

Ensure ~/.composer/vendor/bin is in your PATH:

 echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
  1. Install and Launch Valet :
 valet install

This configures Nginx, dnsmasq, and starts required services via brew services .

  1. Park your projects directory :

Navigate to your projects folder (eg, ~/Sites ) and run:

 cd ~/Sites
valet park

Now, any folder inside ~/Sites will be accessible at http://folder-name.test .

  1. Serve a single project (alternative to park):
 cd ~/Sites/my-project
valet link my-project

Now accessible at http://my-project.test .


Enhance Your Setup with Useful Tools

A great PHP dev environment isn't just about PHP and servers—add these tools to round it out.

  • Database: Install MySQL or MariaDB
 brew install mysql
brew services start mysql

Or use MariaDB:

 brew install mariadb
brew services start mariadb
  • Redis (for caching, queues, etc.)
 brew install redis
brew services start redis
  • PHP Extensions via Homebrew

Valet uses the system PHP, so you can install extensions via:

 brew install php@8.3-redis php@8.3-memcached php@8.3-xdebug

Note: After installing extensions, restart Valet:

 valet restart
  • Xdebug for Debugging

Enable Xdebug with:

 valet use php@8.3 --with-extension=xdebug

Then configure your IDE (eg, VS Code, PhpStorm) to listen on port 9003 (default in modern PHP).


Bonus: Custom Domains and SSL

Valet uses HTTPS by default with trusted local certificates.

  • Trust the Valet CA globally (optional but helpful):
 valet install --with-trusted-ca
  • Use a custom domain (eg, .local instead of .test ):
 valet domain .local

Now your projects are at http://project.local .

  • Secure a site with TLS :
 valet secure project-name

This enables HTTPS for that specific parked site.


Final Tips for a Smooth Workflow

  • Keep PHP updated: brew upgrade php@8.3
  • Restart Valet after major changes: valet restart
  • Use valet which to see which site serves a domain
  • Run valet forget in a project to un-link it

Optimizing PHP development on macOS doesn't require Vagrant or Docker for most use cases. With Homebrew managing your core tools and Valet handling serving and domains, you get a fast, quiet, and powerful local environment that stays out of your way.

Basically: install once, park your code, and go.

The above is the detailed content of Optimizing the PHP Development Experience on macOS with Homebrew and Valet. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
Harnessing the Power of WSL 2 for a Linux-Native PHP Development Workflow Harnessing the Power of WSL 2 for a Linux-Native PHP Development Workflow Jul 26, 2025 am 09:40 AM

WSL2isthenewstandardforseriousPHPdevelopmentonWindows.1.InstallWSL2withUbuntuusingwsl--install,thenupdatewithsudoaptupdate&&sudoaptupgrade-y,keepingprojectsintheLinuxfilesystemforoptimalperformance.2.InstallPHP8.3andComposerviaOnd?ejSury’sPPA

Mastering PHP-FPM and Nginx: A High-Performance Setup Guide Mastering PHP-FPM and Nginx: A High-Performance Setup Guide Jul 25, 2025 am 05:48 AM

NginxhandlesstaticfilesandroutesdynamicrequeststoPHP-FPM,whichprocessesPHPscriptsviaFastCGI;2.OptimizePHP-FPMbyusingUnixsockets,settingpm=dynamicwithappropriatemax_children,spareservers,andmax_requeststobalanceperformanceandmemory;3.ConfigureNginxwit

Setting Up PHP on macOS Setting Up PHP on macOS Jul 17, 2025 am 04:15 AM

It is recommended to use Homebrew to install PHP, run /bin/bash-c"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" to install Homebrew, and then execute brewinstallphp or a specified version such as brewinstallphp@8.1; after installation, edit the php.ini file in the corresponding path to adjust memory_limit, upload_max_filesize, post_max_size and display_

Unlocking Peak PHP Performance: Configuring OPcache and JIT Compilation Unlocking Peak PHP Performance: Configuring OPcache and JIT Compilation Jul 24, 2025 pm 09:58 PM

OPcache and JIT are the core tools for PHP8.0 performance optimization. Correct configuration can significantly improve execution efficiency; 1. Enable OPcache and set opcache.enable=1, opcache.memory_consumption=192, opcache.max_accelerated_files=20000, opcache.validate_timestamps=0 to implement opcode caching and reduce parsing overhead; 2. Configure JIT to enable tracking JIT through opcache.jit_buffer_size=256M and opcache.jit=1254

Demystifying PHP Compilation: Building a Custom PHP from Source for Optimal Performance Demystifying PHP Compilation: Building a Custom PHP from Source for Optimal Performance Jul 25, 2025 am 06:59 AM

CompilingPHPfromsourceisnotnecessaryformostprojectsbutprovidesfullcontrolforpeakperformance,minimalbloat,andspecificoptimizations.2.ItinvolvesconvertingPHP’sCsourcecodeintoexecutables,allowingcustomizationlikestrippingunusedextensions,enablingCPU-spe

Deploying a Scalable PHP Environment on AWS EC2 from Scratch Deploying a Scalable PHP Environment on AWS EC2 from Scratch Jul 26, 2025 am 09:52 AM

LaunchanEC2instancewithAmazonLinux,appropriateinstancetype,securesecuritygroup,andkeypair.2.InstallLAMPstackbyupdatingpackages,installingApache,MariaDB,PHP,startingservices,securingMySQL,andtestingPHP.3.DecouplecomponentsbymovingdatabasetoRDS,storing

Automating Your PHP Environment Setup: Integrating PHP into a CI/CD Pipeline Automating Your PHP Environment Setup: Integrating PHP into a CI/CD Pipeline Jul 26, 2025 am 09:53 AM

ChooseaCI/CDplatformlikeGitHubActionsorGitLabCIfortightversioncontrolintegrationandminimalinfrastructure;2.DefineaconsistentPHPenvironmentusingcontainerizationwithimageslikephp:8.2-cliorcomposer:latestandinstalldependenciesviacomposerinstall--no-inte

Troubleshooting Common PHP Installation Pitfalls: A Diagnostic Checklist Troubleshooting Common PHP Installation Pitfalls: A Diagnostic Checklist Jul 26, 2025 am 09:50 AM

VerifysystemrequirementsanddependenciesbyconfirmingOScompatibilityandinstallingessentiallibrariesandbuildtools,usingpackagemanagerslikeaptoryumtosimplifydependencymanagement.2.CheckPHPconfigurationandcompilationerrorsbyrunningaminimal./configurecomma

See all articles