This is my first time trying laravel, after reading the official documentation, it explains that laravel has its own ecosystem, it has provided various environments to support development. As a newbie, I briefly read that for starters we are highly recommended to install Homestead, but if we are reluctant to follow it because Homestead is a special laravel emulator which is an emulator that is sure to like to use up RAM size, so we are given another alternative using a local server in general, with the note that it must meet the following requirements:
- PHP >= 7.2.0
- BCMath PHP Extension
- Ctype PHP Extension
- JSON PHP Extension
- Mbstring PHP Extension
- OpenSSL PHP Extension
- PDO PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
Well, I'm curious, how do I know that my PHP meets the criteria above? I use Ubuntu, and this is how I find out:
php -m
Well from there I can review, and it turns out I only need to install this (highlighted in red):
- PHP >= 7.2.0
- BCMath PHP Extension
- Ctype PHP Extension
- JSON PHP Extension
- Mbstring PHP Extension
- OpenSSL PHP Extension
- PDO PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
Install BCMath, Mbstring & XML PHP on Ubuntu
My PHP version is 7.2, so I use this command
sudo apt install php7.2-bcmath
If you have checked the PHP module again, it should be available like this,
Wait until the process is complete. Continue installing mbstring, use this command
sudo apt-get install php7.2-mbstring
If you have checked the PHP module again, it should be available like this,
Next, finally we install the PHP XML extension in this way,
sudo apt-get install php7.2-xml
If you have checked the PHP module again, it should be available like this,
Okay, now that all the requirements are met, it's time to continue installing composer.
Install Composer
Okay, the next step is let's install Composer for dependency management, so here's how to do it on ubuntu.
curl -sS https://getcomposer.org/installer | php
Now we make composer available globally, using the following command:
sudo mv composer.phar /usr/local/bin/composer
The purpose of the code above is that we move the "composer.phar" file and rename it to "composer", so that later we just call "composer" in the terminal without ".phar".
Next, let's make the composer file executable in the following way,
chmod +x /usr/local/bin/composer
Okay, done, now we can check the existence of composer in the terminal by typing "composer"
Composer Upgrade
It just so happens that we just installed it for the first time, so it will automatically get the latest version, but I'm sure one day you will find the composer system out of date for a few months. So, how do you update it? Don't use the wrong dependency update command.
So to update/upgrade composer to the latest version, simply use the following command:
composer self update
Install Laravel
Okay, at this stage, I suggest you use an alternative command to install Laravel, which is in the documentation a little lower, like this:
composer create-project --prefer-dist laravel/laravel instabot
The above command implies that "create a project" with the "instabot" folder from "latest version of laravel / latest distribution".
Launch Laravel
First run the development server with the following command:
php artisan serve
Okay, done, you can open it in your favorite browser.