The Tigris Bucket
-
Create a Tigris Bucket
You can create a Tigris bucket through the
flyctlcli. Pro tip: run this command inside a Fly.io initialized project, doing so will allowflyctlto automatically set secrets on your Laravel Fly app using the credentials of your Tigris Bucket:You’ll be asked for a custom name for your bucket, but you can choose to create one with a random name. Once your bucket completes initialization, you’ll receive its credentials in your console. If you did run the create command inside your Laravel Fly app’s project directory, these secrets will automatically get set for your Laravel Fly app: -
Visit your Bucket
Once you’ve taken note of the secrets set above, you can visit this newly created bucket by getting your console link using the
BUCKET_NAMEattribute received from above:Running the command above should give you a link to your bucket’s console dashboard:The link provided will lead straight to your Tigris console, where you should see the name of the bucket you’ve recently created. Of course, you’ll have to be logged in via Fly.io to access this dashboard.
Integrating Laravel with Tigris
Now that we have our Tigris Bucket, let’s connect it with our Laravel app.-
Configure Laravel with S3 driver using Tigris credentials:
Make sure you have the Flysystem S3 package installed for your Laravel project:
Let’s use the credentials of our Tigris bucket as values for our S3 driver:In a local setup, all we have to do is update our .env file with the values above:For a Laravel Fly app, the first two environment variables have already been set as secrets during the creation of the Tigris Bucket. What remains is to set the additional env variables that don’t match:
-
Upload a file from the Controller:
To test out our connection to the Tigris bucket, we can create a sample function that uploads a text file to the bucket:
Calling the function above should upload a new file in your bucket.
Serving public files
If your bucket is public, uploaded objects are accessible without authentication athttps://bucket-name.t3.tigrisfiles.io/key-name. You can use this URL directly in your Blade templates for images, CSS, JavaScript, and other assets. No credentials or pre-signed URLs are needed.
For production use, we recommend setting up a custom domain so your public URLs stay stable. See the Tigris Public Bucket docs for details on all available public domains.