Download the PHP package stechstudio/laravel-shuttle without Composer

On this page you can find all versions of the php package stechstudio/laravel-shuttle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-shuttle

Laravel Shuttle

This package is designed to provide an amazingly simple way to get large-scale file uploading working in a TALL app, directly to S3.

Installation

1. Composer install this package

2. Migrate the database

Shuttle sets up its own uploads table to store details of each file. Your app can then make use of these upload records, or you can move the file information to a different database table after the upload completes.

3. Add the routes

Shuttle will create all the necessary routes for multipart uploads, you just have to tell Shuttle where to define the routes. This way you can wrap any middleware, route prefix, or other requirements.

4. Configure AWS

Make sure you have an s3 disk properly configured in Laravel already. See the advanced config below if you want to change which disk or S3 client Shuttle uses.

The S3 bucket you decide to use needs CORS configured. Open the bucket in the AWS console, click on the permissions tab, scroll down to the CORS box, and paste this:

You can further restrict origins if desired.

Disclaimer
The CORS Everywhere plugin does not play nicely with this package. Make sure that you disable it when developing locally.

Implementation

Implementing Shuttle in your app is pretty simple, let's walk through it.

1. Implement the Blade component

It's time to drop Shuttle into your app. All you have to do is use the Blade component in your view where you want users to upload files. This should be a Livewire view file.

2. Add the upload context

You Livewire component needs to expose a $uploadContext array, with any metadata about the uploaded files that you will need later on to determine ownership.

For example, let's say you have a simple folder/file app. When users upload files to, you will need to add the folder ID to each file upload, so you can determine how to relate the files in the database. Your Folder Livewire component class might look something like this:

3. Tell Shuttle how to relate files

When a file is uploaded, Shuttle needs to know what the owner of the file is. We're not talking about the user that performed the upload, but rather what model the file should be attached to. This is commonly a folder, or a project.

In your AppServiceProvider boot() method, you will need to define a callback function that receives the file metadata (including the context information provided in the previous step). This will return a database model.

So for our folder example above, we might define a callback like this:

Shuttle will now ensure the uploaded files have an owner relationship set to this folder.

You also need to add the HasUploads trait on the owning model. In our example above, this would be the Folder model.

Warning
This is a basic example to get things working. You will most likely want to perform some authorization check in that callback function to ensure the currently logged-in user has permission to upload files to the specified folder.

4. Add relationship to your owning models OR handle completed uploads yourself

If you'd like to make use of the uploads database records directly, there's nothing more to do. You can access $folder->uploads with our previous example setup, and retrieve all uploaded files.

Alternatively, if you prefer to handle uploaded file data on your own, you can wire up a callback that Shuttle will execute when an upload completes. Do this in your AppServiceProvider:

In this case, you probably want to treat Upload records as temporary, and execute a $upload->delete() in the above callback after handling.

Uploading files

At this point you should be able to visit page in your app where you have implemented the Shuttle Blade component and provide upload context in your Livewire component.

Drag some files onto the page, and you should see a translucent overlay appear, letting you know you can drop your files.

Once you drop the files, you should see a bar at the bottom of the page showing the status of your uploads. You can expand this bar to view the individual status of each file as it uploads.

The bar will turn green when all dropped files are successfully uploaded. It will turn red and auto-expand if any uploads fail, showing the error messages.

Events

We expose the following events that you can listen for.

Event Properties
fileAdded $file
uploadProgress $file, $progress
progress $progress
uploadSuccess $file
uploadError $file
fileRemoved $file
complete $result

Customization

You are able to customise the colours of the UI. You just need to go ahead and publish the config file.

php artisan vendor:publish --tag=shuttle-config

CSRF Token

You will need to add the following to your VerifyCsrfToken middleware to prevent a CSRF token mismatch error.


All versions of laravel-shuttle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.1
illuminate/contracts Version ^9.19.0
league/flysystem-aws-s3-v3 Version ^3.0
orchestra/testbench Version ^7.6
spatie/laravel-package-tools Version ^1.9.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package stechstudio/laravel-shuttle contains the following files

Loading the files please wait ....