Laravel

Learn how to configure Laravel for use with Filebase.

What is Laravel?

Laravel is a web application framework written using PHP that offers an easy to read foundation for building web apps.

Laravel can be configured to use S3-compatible storage such as Filebase. Read below to learn how to configure Laravel for use with Filebase.

Prerequisites:

1. Create a new Laravel project with the following command:

composer create-project laravel/laravel PROJECT-NAME

2. Use the cd command to move into the newly created project directory.

3. Create a new file in the ./resources/views directory and name it fileUpload.blade.php with the following contents:

4. Move back into your project’s top directory and open the ./routes/web.php file.

Replace the existing contents with the following:

‘My-file’ refers to the directory that your files will be uploaded to. Change this value to reflect your intended configuration.

5. Move back into your project’s top directory and open the .env file.

Replace the existing contents with the following:

You will need to change the FB_ACCESS_KEY_ID and FB_SECRET_ACCESS_KEY values to reflect your Filebase Access and Secret Keys.

6. Move back into your project’s top directory and open the ./config/filesystems.php file.

Replace the existing contents with the following:

7. Next, install the Laravel driver with the commands:

php artisan make:auth

composer require league/flysystem-aws-s3-v3 "^1.0"

8. Then start your Laravel server with the following command:

php artisan serve

9. Then go to your web browser and navigate tohttp://127.0.0.1:8000.

10. You will see a screen that prompts file uploads.

Each file uploaded will be uploaded to your Filebase bucket that you specified in the .env file.

Last updated

Was this helpful?