Save yourself from agony by using this template for Laravel 5.7
- PHP 7.2
- Laravel 5.7
- Composer
- AWS Cloud9 running on EC2 Instance
To use this project, follow these steps:
AWS Cloud 9 runs on Linux CentOS distriction. You must use, "yum" commands vs "apt-get"
use "yum" vs "apt-get"
Laravel 5.7 requires PHP 7.1 or higher. All AWS CLoud9 EC2 instances come with 5.6 installed. The following steps will removed PHP 5.6 and install PHP 7.2
- Check which version of PHP installed by running:
php -v
- Remove all traces of PHP 5.6:
sudo yum remove php56*
- Install PHP 7.2:
sudo yum install php72*
- Verify PHP 7.2 is installed:
php -v
Composer is an application-level package manager for the PHP. It makes managing dependencies super easy!
Instructions for downloading Composer can be found here: Download Composer
- In your bash terminal, copy and paste the following commands. Be sure to run the last line.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"
2) Check to see if Composer is installed by running: php composer.phar
. You should be able to see the Composer menu and commands.
3) Clean up the command by running the following: sudo mv composer.phar /usr/local/bin/composer
. Now you will be able to access composer by typing in composer
in your bash terminal.
Composer will handle the Laravel installation.
- Install Laravel:
composer create-project laravel/laravel --prefer-dist
- Move all content of this folder to the parent/root level directory and remove the empty folder.
- Show hidden files: In your file menu (left side), click on the gear icon in the upper right. Make sure, "Show Hidden Files" is checked off.
- All Laravel local settings are in your .env file. This is where you store sensative information and this does not get uploaded to your repo. Its up to whoever is setting up their environment to make the correct environment varaibles and settings.
You may install your database locally or connect with AWS RDS database.
- Open your .env file and replace the following with your database credientials:
DB_CONNECTION can be: pgsql, mysql, sqlite, etc
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret
- Migrate your database by entering the following command:
php artisan migrate
Cloud9 only allows port 8080,8081 and 8082. So you must specify which port to run.
- Run server:
php artisan serve --port=8080
. This will run your project on port 8080. - Preview project: on the top, next to the green, "Run" button there is an option to "preview". Select, "Preview Running Application"