With that said, let's get started showing you how to use MAMP so you can get coding and testing websites like a boss! Setting Up Mamp - Download & Install We'll show you how to get started with the free version of MAMP, but it should be noted that the Pro version is pretty inexpensive and streamlines your workflow quite a bit. Having your own local development environment allows you to quickly plug through building a website or application without needing to consider all implications of having an accessible product online. While this workflow is guided towards folks using a Mac, the steps of the process are almost identical on other platforms. This tutorial will walk you through setting up MAMP so you can take advantage of all the perks of having your own local PHP development server. This guide to setting up MAMP will show you how to create your own PHP development server & how to use MAMP efficiently once you're all setup. Utilizing a local development environment is crucial for web developers, but it's not well documented. WP-CLI global config:/Users/developer/.wp-cli/config.Category: Freebies - Web Dev Tools & Graphic Design Freebies, Advanced Web Design Tutorials & CMS Tutorials Php.ini used:/Applications/MAMP/bin/php/php5.5.14/conf/php.ini Here’s the result of `wp cli info` when I run it on my Mac □ PHP binary:/Applications/MAMP/bin/php/php5.5.14/bin/php It’s worth getting it working though, I use WP CLI to install & setup out base install of WordPress and it saves me 45 minutes each install. It’s hard to diagnose from this end, so if you cannot figure it out from the above, then i’m afraid I cannot help. It’s possible that MAMP is not using version 5.5.10 of php (at least I cannot tell from my desk), just double check what version of PHP MAMP is using (you can do this from the MAMP Interface). I’ve included what I get when i run this command at the end of the email.Ĥ. I see you have tried to set it to `/usr/bin/php` which will not work as MAMP doesn’t touch this file at all. You basically need to get this to be your MAMP version. You could try and run `wp cli info` which will tell you which PHP version wp cli is trying to use. Is MAMP running? You get the same error if you try to run the `wp` command when MAMP isn’t running (because the mysql server isn’t running).ģ. Or alternatively you can close terminal and re-open it.Ģ. bash_profile you will need to re-source the file using the `source` command. Here are a couple of things to keep in mind though:ġ. Installing VVV is out of scope for this article, but you can find everything you need to get it up and running on their Github repo. For this reason (and many more), it’s worth investing the time to setup your development environments using VVV (a Vagrant configuration focused on WordPress development). These are the 2 main errors when working with MAMP & WP CLI, but depending on your version of MAMP and version of OSX, it’s possible you will encounter other errors. bash_profile or re-open terminal like before. Press CTRL + O then CTRL + X to save and exit. Within this file, add the following: export PATH=$PATH:/Applications/MAMP/Library/bin This is almost the same process as above, so re-open the ~/.bash_profile file in terminal and type: nano ~/.bash_profile If you have MAMP running and you’re still receiving the “Can’t Connect” error, then you can add MAMP’s MySQL to your system $PATH. You must have MAMP running for WP CLI to connect to the MySQL server. Can’t Connect To Local MySQL Server Through Socket In my example, it would be like this: export PATH="/Applications/MAMP/bin/php/php5.5.14/bin:$PATH" Within this file, add the path to MAMPs PHP. You’ll need to update the WP_CLI_PHP environment variable by add the following code to your ~/.bash_profile or ~/.bashrc file (whichever you prefer). You can replace the version number with your MAMPs PHP version. The exact path to MAMPs PHP install varies depending on the version, but it will be something similar to /Applications/MAMP/bin/php/php5.5.14/bin. You can find out what PHP you’re using by running the command which php in your terminal window. Your default path to PHP is likely to be /usr/bin/php, or /usr/local/bin/php which is not those used by MAMP. MAMP comes packaged with it’s own versions of MySQL & PHP which we need to give WP CLI access to. However for MAMP users it won’t work out of the box, so this is how you fix it: Error Establishing A Database Connection You can setup new installs, install plugins, update settings all from your terminal window. WP CLI is a fantastic command line tool for working with WordPress.
0 Comments
Leave a Reply. |