All Projects → MikeGarde → php-setup-guide

MikeGarde / php-setup-guide

Licence: GPL-3.0 license
How to setup your Mac for PHP development

Programming Languages

PHP
23972 projects - #3 most used programming language
CSS
56736 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to php-setup-guide

Primary Vagrant
An Apache based Vagrant configuration for helping you get the most out of WordPress Development
Stars: ✭ 192 (+700%)
Mutual labels:  xdebug, apache
phuzz
Find exploitable PHP files by parameter fuzzing and function call tracing
Stars: ✭ 53 (+120.83%)
Mutual labels:  xdebug
openwhisk-runtime-go
Apache OpenWhisk Runtime Go supports Apache OpenWhisk functions written in Go
Stars: ✭ 31 (+29.17%)
Mutual labels:  apache
osschat
Apache Open Source Software Chat BOT
Stars: ✭ 115 (+379.17%)
Mutual labels:  apache
homebrew-extensions
🍻 Homebrew tap for PHP extensions
Stars: ✭ 264 (+1000%)
Mutual labels:  xdebug
geostat
GeoStat, Python script for parsing Nginx and Apache logs files and getting GEO data from incoming IP's.
Stars: ✭ 50 (+108.33%)
Mutual labels:  apache
CVE-2021-41773 CVE-2021-42013
Apache HTTP Server 2.4.49, 2.4.50 - Path Traversal & RCE
Stars: ✭ 20 (-16.67%)
Mutual labels:  apache
cloudworkstation
A linux desktop in the cloud - reachable via browser using Apache Guacamole. Deployed automatically via Terraform ( + Ansible ).
Stars: ✭ 66 (+175%)
Mutual labels:  apache
roxy-wi
Web interface for managing Haproxy, Nginx, Apache and Keepalived servers
Stars: ✭ 1,109 (+4520.83%)
Mutual labels:  apache
php8-xdebug
PHP 8.0 for development and production usage. With nginx, brotli, xdebug, JIT and more...
Stars: ✭ 17 (-29.17%)
Mutual labels:  xdebug
kafka-shell
⚡A supercharged, interactive Kafka shell built on top of the existing Kafka CLI tools.
Stars: ✭ 107 (+345.83%)
Mutual labels:  apache
kuberay
A toolkit to run Ray applications on Kubernetes
Stars: ✭ 146 (+508.33%)
Mutual labels:  apache
MonitoFi
MonitoFi: Health & Performance Monitor for your Apache NiFi
Stars: ✭ 40 (+66.67%)
Mutual labels:  apache
easy-git-deploy
Tired of complex shell scripts for managing GIT on your web server? This tool has exactly one button for each direction. Handle deployments for smaller projects (e.g. Static websites, 🅰️Angular apps, Wordpress, etc.) with ease.
Stars: ✭ 47 (+95.83%)
Mutual labels:  apache
incubator-nlpcraft
Apache NLPCraft - API to convert natural language into actions.
Stars: ✭ 56 (+133.33%)
Mutual labels:  apache
uima-uimaj
Apache UIMA Java SDK
Stars: ✭ 50 (+108.33%)
Mutual labels:  apache
hive-jdbc-driver
An alternative to the "hive standalone" jar for connecting Java applications to Apache Hive via JDBC
Stars: ✭ 31 (+29.17%)
Mutual labels:  apache
IATI.cloud
The open-source IATI datastore for IATI data with RESTful web API providing XML, JSON, CSV output. It extracts and parses IATI XML files referenced in the IATI Registry and powered by Apache Solr.
Stars: ✭ 35 (+45.83%)
Mutual labels:  apache
docker-laravel-8
A simple Docker - Laravel 8 - MySQL - Redis - PHPAdmin - NGINX - PHP 7.4 - Composer - Artisan - XDebug
Stars: ✭ 130 (+441.67%)
Mutual labels:  xdebug
lucene-geo-gazetteer
Uses Apache Lucene, OpenNLP and geonames and extracts locations from text and geocodes them.
Stars: ✭ 34 (+41.67%)
Mutual labels:  apache

WARNING

homebrew has removed PHP 5.6 and this guide needs to be updated

PHP Development on MacOs High Sierra

This guide will get your machine ready for web development using PHP, Apache, and XDebug. As a consequence we will also setup a handful of other tools. If you find a problem with anything please let me know by creating an issue.

Show hidden files

defaults write com.apple.finder AppleShowAllFiles YES && killall Finder

Homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor

Apache

Your macOs shipped with a copy of Apache, unfortunately it is missing key pieces we need so we will install a second copy of Apache. Note that apachectl -k graceful and other apachectl commands will still be how you interact with appache. Also, if you're doing this after a clean install you won't be running apache so the first command may result in an error, you can ignore that error and run the second command.

sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null

Install Apache using brew

brew install httpd

Start Apache Server

apachectl start

You can test by visiting http://localhost:8080

PHP

We are going to install both PHP 5.6 and 7.1, as 7.2 is not yet stable. However your machine will only be able to use one version at a time.

brew tap homebrew/php
brew install php71 --with-httpd
brew unlink php71
brew install php56 --with-httpd

PHP Xdebug

Note that un-linking is not required here because the proper version will be referenced in the php.ini file.

brew install php71-xdebug
brew install php56-xdebug

Config Files

Create development folder, note that if you decide to use a different location note it in future instructions you will have to reference it properly, I am using the folder dev inside my home folder.

mkdir ~/dev
mkdir ~/dev/logs
mkdir ~/dev/logs/xdebug
git clone https://github.com/MikeGarde/php-setup-guide.git ~/dev/php-setup-guide

These commands will allow for easy access to all of our config files.

ln -s $(brew --prefix)/etc/php/7.1/php.ini ~/dev/php71.ini
ln -s $(brew --prefix)/etc/php/5.6/php.ini ~/dev/php56.ini
ln -s $(brew --prefix)/etc/php/7.1/conf.d/ext-xdebug.ini ~/dev/php71-xdebug.ini
ln -s $(brew --prefix)/etc/php/5.6/conf.d/ext-xdebug.ini ~/dev/php56-xdebug.ini
ln -s $(brew --prefix)/etc/httpd/httpd.conf ~/dev/httpd.conf
ln -s $(brew --prefix)/etc/httpd/extra/httpd-vhosts.conf ~/dev/httpd-vhosts.conf
ln -s ~/dev/php-setup-guide/localhost.php ~/dev/index.php

dnsmasq

This will route all traffic ending with .test to your machine so that you don't have to setup each project and domain. Note, you don't have to use .test, you can replace it with whatever you want however .dev was purchased by Google and Chrome may not honor your desired actions in the future. Other options are .localhost .example where as .local may compete with other devices on your network.

After the install when you create the directory etc you may get an error if the directory already exists however this should work, you can verify by running vi $(brew --prefix)/etc/dnsmasq.conf (:q to quit) however it shouldn't be necessary.

brew install dnsmasq
cd $(brew --prefix); mkdir etc; echo 'address=/.test/127.0.0.1' > etc/dnsmasq.conf'
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo mkdir /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/test'
ping -c 1 me.test # will demonstrate that your machine will resolve me.test to your local machine
cd ~

Apache Setup

Now that we are routing .test traffic to your machine we will get apache to resolve it to the proper directory within your development folder.

Open ~/dev/php-setup-guide/httpd.conf and replace all YOUR_HOME_FOLDER references with your home folder location and YOUR_USER_NAME. Next use the resulting file and replace ~/dev/httpd.conf with it.

Open ~/dev/httpd-vhosts.conf, you can delete everything and replace it with this.

<VirtualHost *:80>
    DocumentRoot "/Users/YOUR_HOME_FOLDER/dev"
    ServerName localhost
    ServerAlias localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/Users/YOUR_HOME_FOLDER/dev/php-setup-guide"
    ServerAlias php-setup-guide.test
    ErrorLog "/Users/YOUR_HOME_FOLDER/dev/logs/php-setup-guide-error_log"
    CustomLog "/Users/YOUR_HOME_FOLDER/dev/logs/php-setup-guide-access_log" common
</VirtualHost>

Anytime you modify httpd.conf or httpd-vhosts.conf file you will need to restart apache,

sudo apachectl -k graceful

Xdebug Setup

Add the following to both of your ~/dev/xdebug.ini files, the last two lines are for more detailed debugging.

xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_host=127.0.0.1
;xdebug.profiler_enable=1
;xdebug.profiler_output_dir="/Users/YOURNAME/dev/logs/xdebug"
sudo apachectl -k graceful

If there is a problem with using port 9000 you can change it but note it when setting up Xdebug in your IDE.

Composer

Follow instructions at Composer, when done make it globally available by moving it.

mv composer.phar /usr/local/bin/composer

And You're Done, Let's Test

If you haven't already...

sudo apachectl -k graceful

http://php-setup-guide.test/ will show you a hello world while http://localhost/ will give you phpinfo and links to your projects.

Adding Projects

Open ~/dev/httpd-vhosts.conf and copy the php-setup-guide example, if you don't need separated logging simply remove the ErrorLog and/or CustomLog lines.

Switching between PHP 5.6 and 7.1

Switching to 5.6 Switching to 7.1
brew unlink php71 brew unlink php56
brew link php56 brew link php71

Update httpd.conf appropriately.

#LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
sudo apachectl -k graceful

QCacheGrind for PHP Memory Profiling

brew install qcachegrind
brew install graphviz

Enable Xdebug profile logging in your appropriate ~/dev/php56-xdebug.ini file.

xdebug.profiler_enable=1
xdebug.profiler_output_dir="/Users/mikegarde/dev/logs/xdebug"
sudo apachectl -k graceful

To see results make a request to your machine invoking xdebug, this will create a new file in ~/dev/logs/xdebug. Reference that when running the following or open ⌘ + space qcachegrind and open the file. Note that using the command line will give you additional information when performing actions within QCacheGrind.

qcachegrind # OR
qcachegrind ~/dev/logs/xdebug/cachegrind.out.23938

Extra Stuff I Use

AWS CLI

brew install awscli
aws configure

Python 3

brew install python3
curl -O https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
rm get-pip.py

Good Stuff

PHP Specific Stuff

  • Rollbar you'll stop hating your users. "Something wen't wrong, sorry I can't explain what I was doing."

Keyboard Shortcuts

Download Alfred 3, I disable ⌘ + space in my keyboard shortcuts an setup Alfred to open using the same command.

Alfred Settings 1 Alfred Settings 2

Screen shot replacement commands.

Easy Screen Shots

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].