As a developer, I’m constantly looking for efficient ways to streamline my workflow. For the kind of projects I’m building—simple, PHP-driven brochure websites with no database (for now)—I don’t need a complex web server setup. Instead, I’ve opted for the built-in PHP web server, which makes local development super easy and fast.
I’m also in the process of creating a custom PHP framework to replace some of my WordPress projects, giving me more flexibility and control over my websites. If you’re in a similar boat and want to get started with PHP development, here’s how I set things up on CachyOS. This guide should also work on all Arch-based distros (like Manjaro, Arch Linux, and others).
1. Installing PHP on CachyOS
The first step is to install PHP. CachyOS (like all Arch-based distros) makes this super simple thanks to the pacman
package manager. Here’s how I installed PHP:
sudo pacman -S php
This command installs PHP 8.3—the latest version available in the official Arch repositories as of December 2024. For simple PHP development, this is all I need. If you need a different version (e.g., PHP 7.x or PHP 8.2), you can easily specify that in the pacman
command. But for most purposes, the latest stable version works just fine.
2. Testing Locally with PHP’s Built-in Web Server
Since I’m focusing on a simple PHP framework, I don’t need the overhead of setting up a full Apache or Nginx server. Instead, I use PHP’s built-in server, which is lightweight and perfect for development and testing. Here’s how I get it running:
- Navigate to the project directory (where my PHP files are located).
- Start the PHP server with the following command:
php -S localhost:8000
This command starts the PHP server on localhost at port 8000. Now, I can visit http://localhost:8000
in my web browser to see my website or web application in action.
For small projects or when developing custom PHP frameworks, this method is quick and efficient. No need to fiddle with complex configurations or external servers.
3. Why XAMPP Is a Great Option for Additional Testing
If you’re just getting started with PHP or need to test your sites in a more robust local environment, XAMPP is a great option to consider. XAMPP is a free, open-source software package that includes everything you need to run a web server on your local machine: Apache, MySQL, and PHP.
You can download XAMPP for Linux, Windows, or macOS. Here’s why XAMPP might be ideal for many developers, especially those without access to a live web server:
- Easy Setup: XAMPP takes care of the installation and configuration of Apache and MySQL, so you don’t have to worry about setting up these services manually.
- Perfect for Testing: Whether you’re building a new PHP framework, testing database-driven sites, or learning PHP, XAMPP is a one-stop solution that simulates a real web environment.
- No Live Server? No Problem! XAMPP is ideal if you don’t have access to a live server for testing or deployment. You can run your PHP projects locally, just like they would run on a live web server, without the need for an internet connection.
To install XAMPP on CachyOS (or any Arch-based system), you can follow the instructions from the official XAMPP website or use the AUR package manager (yay
or paru
) to install it via the AUR.
paru -Ss xampp
Once XAMPP is installed, you can start Apache and MySQL via the XAMPP control panel and use it as your local development environment.
4. Next Steps: Building The PHP Framework
![Screenshot of a custom PHP framework in development, showing the structure and code for a simple brochure website.](https://ernstrenner.com/wp-content/uploads/2024/12/custom-php-framework-for-simple-web-development.webp)
Since I’m currently working on a custom PHP framework to replace some of my WordPress pages, using the PHP built-in server has been perfect for development. I’m creating a lightweight framework that will help me build websites faster and with more control over the codebase. By using pure PHP, I can focus on crafting cleaner, more efficient pages that are fast and easy to maintain.
Once I’m ready to deploy my sites to a live server, I’ll migrate them over to a web hosting provider that supports PHP.
Final Thoughts
Getting started with PHP on CachyOS is easy, especially if you’re working on small projects or creating a custom framework like I am. You don’t need a lot of extra software—just PHP, a text editor, and either PHP’s built-in server or XAMPP for more robust local testing.
This approach is ideal for anyone looking to quickly develop simple PHP-driven websites without the complexity of setting up a full production server. And if you need a more advanced local development environment (with Apache and MySQL), XAMPP is an excellent choice, especially for those who don’t have access to a live web server.
Whether you’re building your own PHP framework or just testing a small brochure site, this setup should work perfectly for you.