Laravel environment basic settings
Introduction to environment setup for Laravel, including composer installation
Configuration and package installation required for developing Laravel projects, applicable whether on remote hosts or local machines.
Update Packages
sudo apt-get update
Install Composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Result
Composer (version 2.0.12) successfully installed to: //composer.phar
Use it: php composer.phar
Making it Global
After this, you can directly use the composer
command. It’s very convenient and recommended.
mv composer.phar /usr/local/bin/composer
Install PHP Extensions
For PHP version 7.4 hosts, to run composer install
outside the container, the following extensions need to be installed:
- php7.4-mbstring
- php7.4-cli
- php7.4-gd
- ext-dom (php-xml)
- zip unzip php7.4-zip
apt install php7.4-cli
apt-get install mbstring ext-dom zip unzip php7.4-zip php7.4-mbstring php-xml php7.4-gd
Installing Database-related Extensions
Install extensions according to the database used by the project, for example:
- php7.4-pgsql
- php7.4-mysql
Necessary Extensions for php artisan
php artisan
needs to be executed under the PHP Command Line Interface (CLI), so install the CLI package according to your PHP version.
apt install php7.4-cli
The above steps cover the basic setup required for Laravel environment.
For users using containers, execute these steps when building the PHP image.