https://ahmadrosid.com/images/macos-for-laravel.png
Congratulations on your recent purchase of a MacBook! If you intend to use it for Laravel development, you have come to the right place. Allow me to guide you through the necessary steps for setting up your MacBook for a Laravel development environment.
Install PHP
To install PHP on macOS, you can use the package manager Homebrew. First, make sure you have Homebrew installed by running the following command in your terminal:
If you don’t have Homebrew installed, you can install it by running the following command:
Once you have Homebrew installed, you can install PHP by running the following command:
If you want to install specific php version you can search available php package in brew.
For example if you want to install php version 8 just.
Now export path for binary php, change ~/.zshrc
to whatever shell you are using in this case I use zsh.
Install composer
To install Composer, you can follow the instructions on the Composer website: https://getcomposer.org/download. Here is a brief summary of the steps to install Composer on macOS:
Download the Composer installer by running the following command in your terminal:
Move the Composer binary to a directory that is included in your system path by running the following command:
Verify that Composer is installed by running the following command:
This should print the version of Composer that is installed on your machine
Install Laravel
This is optional. But if you want to create new project quickly you can use it directly from composer.
You also can create laravel project using the official cli. First install the cli.
Now export binary path.
And here’s how to create project from it.
Install MySQL
Most people use MySQL for Laravel projects. You might as well if you do. Please follow the instructions below for installation.
This will install the latest version of MySQL on your machine. You can verify that MySQL is installed by running the following command:
This should print the version of MySQL that is installed on your machine.
After installing MySQL, you will also need to start the MySQL server. You can do this by running the following command:
This will start the MySQL server in the background. To stop the MySQL server, you can run the following command:
To secure a MySQL installation, you can follow these steps:
Set a strong password for the MySQL root user: By default, the MySQL root user has no password, so you should set a strong password for the root user to prevent unauthorized access to your MySQL server. You can do this by running the following command:
Replace new_password
with a strong password of your choice.
Reload the privilege tables: After making changes to the MySQL user accounts and permissions, you will need to reload the privilege tables to apply the changes. You can do this by running the following command:
I hope this helps! Let me know if you have any other questions.
Laravel News Links