Tell me for any kind of development solution

Edit Template

Effortlessly Manage PHP Versions with Laravel Herd

Juggling PHP versions with Laravel Herd is a common challenge for developers maintaining legacy systems or testing new features. Laravel Herd eliminates this headache by offering a streamlined way to install, switch, and isolate PHP versions—no manual configuration required. Whether you’re a CLI enthusiast or prefer GUI tools, this guide walks you through practical steps to master PHP version management, optimize performance, and solve real-world development pain points.


Why Managing PHP Versions with Laravel Herd Matters

PHP updates improve security and performance, but older projects often depend on specific versions. Without proper management, developers face:

  • Broken workflows when global PHP versions clash with project requirements.
  • Security risks from outdated, unsupported PHP installations.
  • Wasted time manually editing php.ini files or restarting servers.

Laravel Herd solves these issues by letting you:

  • Switch PHP versions globally or per project in seconds.
  • Automatically apply configuration changes.
  • Maintain a clean development environment.

Step 1: Install and Configure PHP Versions

Herd defaults to PHP 8.3 but supports versions from 7.4 onward.

GUI Method:

  1. Open Herd’s PHP Settings from the menu bar.
  2. Click “Install” next to your desired version (e.g., 8.2, 8.1).
  3. Set the global default via the dropdown.

CLI Shortcuts:

herd install 8.2          # Install PHP 8.2 
herd use 8.1              # Set global version to 8.1 
herd uninstall 7.4        # Remove unused versions

Pro Tip: Need PHP 7.3 or lower? While Herd doesn’t officially support EOL versions, you can:

  • Use Docker for legacy projects.
  • Manually compile PHP and link it to Herd.

Step 2: Isolate PHP Versions Per Project

Herd’s per-site isolation ensures projects use their required PHP version, regardless of global settings.

GUI Workflow:

  1. Open Site Manager in Herd.
  2. Select your project and choose a PHP version from the dropdown.
  3. Click “Restart” to apply changes.

CLI Commands:

cd ~/projects/legacy-app 
herd isolate 8.0 --site="Legacy Project"   # Assign PHP 8.0 
herd isolated                              # List all isolated projects 
herd unisolate                             # Revert to global version 

Step 3: Optimize PHP Configuration

Tweak settings like memory limits without digging into config files:

Quick Edits via GUI:

  1. Right-click Herd’s menu icon > PHP Settings > Open php.ini.
  2. Adjust values (e.g., memory_limit = 2G).

CLI Shortcuts:

herd ini                 # Open php.ini for the active PHP version 
herd restart             # Apply changes system-wide 

Critical Settings to Adjust:

  • upload_max_filesize (Increase for large file uploads).
  • max_execution_time (Extend for long-running scripts).

Real-World Use Cases for PHP Versions with Laravel Herd

Case 1: Maintaining Legacy Apps

A team supporting a PHP 7.4 e-commerce platform used Herd to:

  • Keep the production-alike environment on 7.4.
  • Develop new features in PHP 8.3.
  • Switch contexts instantly without Docker/VMs.

Case 2: Streamlined Team Collaboration

Onboard new developers faster by sharing Herd’s isolated environment settings instead of complex setup guides.


Advanced Tips for Power Users

Proxy PHP Tools:

Run CLI commands using the project’s PHP version:

herd composer install    # Uses isolated PHP version 
herd php artisan migrate 

Troubleshoot Conflicts:

  • Force-stop services by holding Option + clicking Herd’s menu > Force Stop All.
  • Check active versions with herd which-php.

Best Practices for Managing PHP Versions with Laravel Herd

  • Audit Projects Quarterly: Identify outdated PHP dependencies using tools like PHPCompatibility.
  • Limit Isolation: Only isolate projects requiring non-standard versions to reduce overhead.
  • Monitor EOL Deadlines: Track version lifecycles at endoflife.date/php.

Final Thoughts

Mastering PHP versions with Laravel Herd ensures smoother development, tighter security, and better team collaboration. By leveraging Herd’s GUI and CLI tools, you eliminate the friction of PHP management and focus on building great applications.


FAQs

1. How do I switch PHP versions globally in Laravel Herd?

Use the CLI command herd use [version] (e.g., herd use 8.2) or select the desired version from Herd’s menu bar dropdown in the GUI.

2. Can I install PHP 7.3 or lower with Laravel Herd?

No, Herd officially supports PHP 7.4 and above. For older versions, use Docker containers or manually compile PHP and link it to Herd.

3. How to set different PHP versions for specific projects?

Navigate to the project directory and run herd isolate [version] –site=”Project Name”. Alternatively, use Herd’s Site Manager in the GUI.

4. How do I check which PHP version a project is using?

Run herd isolated to list all projects with custom PHP versions or herd which-php inside the project directory.

5. Why isn’t my PHP configuration change applying?

After editing php.ini, restart Herd services via herd restart or click Restart All Services in the GUI. Ensure no stale processes are running.

6. How to revert a project to Herd’s global PHP version?

Run herd unisolate in the project directory or remove the project’s isolation settings in the Site Manager.

7. Does Laravel Herd support PHP 8.3?

Yes! Herd ships with PHP 8.3 by default, and you can install newer versions as they’re released via the PHP Settings tab or CLI.

Share Article:

© 2025 Created by ArtisansTech