PHP Environment Setup

· 2 min read

Debating which programming language is superior is quite pointless - languages are tools, and what matters is the thinking behind them. Choose what suits your needs and preferences. Objectively speaking, PHP is an excellent language that has thrived for many years and certainly has its merits.

Since some legacy projects are developed in PHP, it’s essential to ensure the development machine has a proper PHP environment. Here’s a record of the PHP environment setup process.

Windows

Recommended to use phpstudy - Download Link

Note: phpstudy does not have a Mac version

phpstudy comes pre-packaged with:

  • Apache
  • PHP
  • etc.

By installing this tool, you can quickly set up the environment.

Of course, XAMPP and wampserver are also viable alternatives.

Mac

Starting from OS X 10.0.0, PHP has been included as a standard component in Mac systems. Original documentation can be found here. However, if you try to access it directly through a browser, you may encounter the following errors.

Therefore, it’s recommended to reinstall PHP. Execute the following command, then configure it in PHPStorm. curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
After this, accessing the page through the browser should work properly.

Apache Configuration

PHP projects need to run under Apache. Simply configuring the path may result in 403 errors, so additional configuration is required. Below is the modified configuration - it’s recommended to backup the original configuration file before making changes.

<Directory />
    Options  Indexes  FollowSymLinks
    AllowOverride None
   Order deny,allow
    Allow from all
</Directory>


DocumentRoot "/Users/juliana/newsp/testing/Test/www"
<Directory "/Users/juliana/newsp/testing/Test/www">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options FollowSymLinks Multiviews
    MultiviewsMatch Any


    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    # AllowOverride None
      AllowOverride All


    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

Final Thoughts

Setting up a proper PHP development environment is essential for working with legacy PHP projects. The tools and configurations mentioned here provide a solid foundation for PHP development on both Windows and macOS platforms. Remember to always backup your configuration files before making changes, and test your setup thoroughly to ensure everything works as expected.

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover