Categories
Web Development

Import large database files to MySQL using Terminal with MAMP

/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot DBNAME < /Users/robertannett/Downloads/DBFILENAME.sql

 

Categories
OSX Web Development

Simpler way of adding intl.so for CakePHP3 on OSX with Mamp

In a Nutshell we just need to do get the full binary package of PHP and install it on OSX, this version comes with intl.so, and we will copy it out of its install directory and drop it into our PHP version.

Get & Install the Binary Package

This website provides the packages so we just pick the version we want to use and run their install script: https://php-osx.liip.ch/

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6

This would install php 5.6 and we we can copy the intl.so file out of the install directory and drop it in our PHP folder.

PHP 5.6.31:

cp /usr/local/php5-5.6.31-20170817-164511/lib/php/extensions/no-debug-non-zts-20131226/intl.so /Applications/MAMP/bin/php/php5.6.31/lib/php/extensions/no-debug-non-zts-20131226

In this example I am using Mamp so I should drop it into the extensions/no-debug-non-zts-20131226 folder of my PHP version.  These are the same version of PHP so the path should be the same, its just that Mamp holds its PHP binary files in the MAMP app.

PHP 7.3.8:

cp /usr/local/php5-7.3.8-20190811-205217/lib/php/extensions/no-debug-non-zts-20180731/intl.so /Applications/MAMP/bin/php/php7.3.8/lib/php/extensions/no-debug-non-zts-20180731/

 

Enable the extension

Find the php.ini file for the version of php you want to use in my case I was using php5.6.31 (you can tell from copy/paste terminal line), and under “Extensions” add the line:

extension=intl.so

And restart Mamp, and your extension should now be installed!

Set PHP version for Terminal – Required for CakePHP / Composer based installs

Frustratingly, terminal often runs a different version of PHP when installing with composer, so for example, CakePHP refuses to install because its running a version of PHP that doesn’t have intl.so. installed.  Check your version of PHP in terminal by typing:

php -v

if it is a different version that the one you want, set the correct one by using an alias in your .bashrc file.

sudo nano ~/.bashrc

Add the line (Replace php path with your path):

alias php="/Applications/MAMP/bin/php/php5.6.31/bin/php"

Then finally reload your bashrc file with:

source ~/.bashrc

You also may need to use this guide to include the php version to terminal if the above doesn’t work: https://stackoverflow.com/questions/30941506/sqlstate-hy000-2002-while-running-bake-command

Sources:

Categories
Web Development

Setting up a Local Domain

MAMP

Before attempting to setup a local domain ensure MAMP has the following setting:

  1. Ports
    • Apache 80
    • Nginx 7888
    • MySQL 3306
  2. Web Server
    • Server Apache
    • Document Root Applications/MAMP//htdocs (or personal preference)

Local Domains

  1. Create the local URL you want to use
    • Go to Macintosh HD/private/etc/hosts
    • At the bottom add….

      127.0.0.1 example.ld
    • Save file
  2. Ensure Virtual Hosts is enabled in your server Conf file
    • Go to Applications/MAMP/conf/apache/httpd.conf
    • Uncomment the following line…

      Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
    • Save file
  3. In the Virtual Hosts file configure your local domain settings
    • Go to Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
    • At the bottom adding the following:

      <VirtualHost *:80>
      ServerAlias example.ld
      ServerAdmin [email protected]
      DocumentRoot /Applications/MAMP/htdocs/example
      </VirtualHost>

Testing

To test your domain is working, go to the following URL

  • http://example.ld