kalamuna / terminatur

What terminus began, terminatur finished: Drush CODESCIENCE for Pantheon Integration
MIT License
11 stars 7 forks source link

Add support for MAMP/MAMP PRO #1

Open pirog opened 10 years ago

pirog commented 10 years ago

Would be great to provide terminatur.mamp.inc to get this to work on MAMP/MAMP PRO. Looks like checking to see if the user is running MAMP and adding vhosts to OSX Apache is easy enough: http://foundationphp.com/tutorials/vhosts_mamp.php

Can use https://github.com/kalamuna/terminatur/blob/master/environment/terminatur.default.inc as a template. Just need to replace default with mamp and edit the constants appropriately. Can probably copy the etc/hosts and server restart commands from kalastack.inc and model after the vhost ones but adapted for the above link.

Then want to provide some sort of identification function into _terminatur_get_environment() in terminatur.drush.inc presumably just checking whether the app exists or not?

@andrewmallis might want to give it a shot?

andrewmallis commented 10 years ago

Challenges

MAMP vs MAMP PRO vhosts

I'm not sure how to detect if MAMP or MAMP PRO is in operation on the user's system. This is impactful, because while both versions point to the same binaries, each has their own config files for Apache, and this will determine how the vhosts get created. We should just hammer both with our own include in httpd.conf and write to that:

Include /path/to/our/httpd-termintur.conf

We can likely use this same file outside of MAMP too.

ports

The user can configure quite a bit in the App, such as the user/group running services (myuser/mygroup or www/mysql) and the ports they run on (Apache/MySQL/SSL: 8888/8889/8890, 80/3306/443, or custom with PRO only)

default webroot

Default MAMP webroot is /Applications/MAMP/htdocs but there is no default for MAMP PRO, the user can navigate the file system we may need to parse the httpd.conf file

Apache

It's not trivial to get either flavor of mamp to restart via the command line. This should, but does not work:

/Applications/MAMP/bin/apache2/bin/apachectl restart

I've tried over the years to get command-line control of apache to work, but it never really took. MySQL is no problem; it's just Apache that's problematic. We could prompt the user to restart MAMP services via the control panel once the vhost is created.

MAMP stores its config in a writeable file at /Applications/MAMP/conf/apache/httpd.conf but MAMP PRO uses templates

MySQL


/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot

will let you connect to MySQL, but if the user has changed the root password (this is encouraged by the UI), we'll want to make the prompt clear

PHP & Drush support in MAMP

While we want to assume that the user has their Drush set up under MAMP, this can prove tricky. These are paths to the multiple PHP binaries. MAMP can switch between these through the UI. There are different versions of PHP depending on the version of MAMP.

/Applications/MAMP/bin/php/php5.2.17/bin
/Applications/MAMP/bin/php/php5.3.14/bin
/Applications/MAMP/bin/php/php5.4.4/bin

Drush, and by extension Terminus and Termintur will want to find the webserver's PHP binary. The command line won't connect there for the user unless declared in their $PATH.

Resources