Menggunakan Mac sebagai komputer untuk coding sama mudahnya dengan menggunakan Linux ataupun Windows, yang perlu diperhatikan adalah perbedaan PATH ataupun cara install. Diluar itu sebagian besar bisa dibilang memiliki kemiripan dari segi penggunaan. Untuk anda yang baru menggunakan Mac, disini akan kita bahas cara cepat untuk menginstall system Mac anda, agar siap tempur untuk develop aplikasi PHP.

Install brew

brew adalah package manager yang paling populer digunakan di Mac, brew ini mirip dengan apt (Debian/Ubuntu) dan dnf/yum (Fedora/CentOS). Cara installnya sangat mudah

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install PHP

Install PHP versi terbaru

brew install php

output

==> Caveats
==> php
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so
 
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>
 
Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html
 
The php.ini and php-fpm.ini file can be found in:
    /opt/homebrew/etc/php/8.1/
 
To restart php after an upgrade:
  brew services restart php
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/php/sbin/php-fpm --nodaemonize

Install PHP brew macos

setelah terinstall, versi PHP bisa diversifikasi

➜  ~ php -v
PHP 8.1.11 (cli) (built: Sep 29 2022 19:44:28) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.11, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.11, Copyright (c), by Zend Technologies

Install composer

Setelah PHP terinstall sekarang install composer, package managernya PHP. Bila anda bekerja dengan framework PHP modern, kemungkinan besar akan menggunakan composer untuk mengelola dependency.

brew install composer

Install MariaDB

Untuk menginstall MariaDB, gunakan perintah

brew install mariadb

output

🍺  /opt/homebrew/Cellar/mariadb/10.8.3_1: 917 files, 174.7MB
==> Running `brew cleanup mariadb`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> mariadb
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
 
MySQL is configured to only allow connections from localhost by default
 
To restart mariadb after an upgrade:
  brew services restart mariadb
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/mariadb/bin/mysqld_safe --datadir=/opt/homebrew/var/mysql

Mac install mariadb
sesaat instalasi selesai, akan ditampilkan versi MariaDB yang terinstall.

Jalankan MariaDB

brew services start mariadb

MariaDB sekarang bisa diakses dari terminal, dengan menjalankan mysql
menjalankan mysql mariadb mac

Install Laravel

Setelah PHP dan MySQL/MariaDB terinstall, kita akan mencoba untuk menginstall Laravel

mkdir ~/code
cd ~/code
composer create-project laravel/laravel laravel9

install laravel dengan composer

pindah ke folder laravel9 yang baru dibuat, lalu jalankan php artisan serve. Di browser buka http://localhost:8000
php artisan serve
tampilan default install laravel

Text Editor

Sesuaikan dengan pilihan anda
Visual Studio Code

brew install --cask visual-studio-code

atau bisa langsung di download dari situs vscode
Sublime Text

brew install --cask sublime-text

atau bisa langsung di download dari situs Sublime Text

Leave a comment

Your email address will not be published. Required fields are marked *