Skip to main content

How do I use Laravel with Tenbyte?

Laravel is validated for use with Tenbyte. To use this product with Tenbyte, please follow the instructions below.
  1. Set up your Tenbyte account and create a bucket as described here.
  2. Install Composer using the CLI.
  3. Create a new Laravel project using the following command. You will receive the following output on the terminal once it is successfully created:
image loading
  1. Go inside your project using the cd command and you will see the project files inside.
    image loading
  2. Now we will need to edit certain files inside this project to make this work with S3-style storage. You can either use any editor to edit the files (e.g. vim or nano) or make use of an IDE to search and edit them easily (e.g. Atom or Visual Studio Code).
  3. Once you have the framework open in an IDE, create a new .php file in resources -> views and name it fileUpload.blade.php.
    Note: We recommend using the same name for the test as we have used this name when referencing in other files. The hierarchy would look like this
    image loading
    Paste the below code in fileUpload.blade.php:
  4. Now go to routes -> web.php and replace the file with the following code:
    Note: The directory here is my-file and your files will be uploaded inside it. We are also passing Tenbyte as a driver, which we will configure later in filesystems.php to specify our custom-defined driver to pass user input.
  5. Go to the root of your Laravel project and open the .env file, then replace its contents with the following code.
    NOTE: Make sure to use your correct Access Key, Secret Access Key, Tenbyte bucket region, Tenbyte Bucket Name, and Tenbyte Region URL.
    Note: This example uses Tenbyte’s us-east-1 storage region. To use other Tenbyte storage regions, please use the appropriate Tenbyte service URL.
  6. Now you need to create a new driver, as S3 has amazonaws.com hardcoded in the library. Go to config -> filesystems.php and replace with the following code:
  7. As the Tenbyte/S3 driver is not the default driver for uploading in Laravel, we need a Composer package to make this work. You can get this package on the Laravel website.
    image loading
    Now on the CLI, go inside your Laravel project and run the following commands. For Laravel 5 and below:
    For Laravel 6 and above (recommended):
    Then run:
    Output
    image loading
  8. Run your code using the following command and the server will start listening on port 8000:
    Output
    image loading
    On the browser, navigate to http://127.0.0.1:8000 and you will be prompted to upload files to your Tenbyte bucket. Once submitted, your files will be visible inside the bucket.
    image loading
    image loading