Download the PHP package luchavez/simple-files without Composer

On this page you can find all versions of the php package luchavez/simple-files. 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 simple-files

Simple Files for Laravel 9|10

Latest Version on Packagist Total Downloads GitHub Repo stars Discord Twitter Follow

Introduction

Implementing a public-private filesystem structure to your Laravel application can be a hassle. But with "luchavez/simple-files", it's easy! This package is built with that in mind so that you can proceed with more important things in your project. It's perfect for Laravel applications that need to work with files. And the best part? It can process not only uploaded files but also Base64 strings and image URLs! Plus, it's especially effective on AWS S3 buckets. Try it out today and see how it can help you!

Check out the examples below to get a clearer picture.

Installation

Via Composer

Setting Up

  1. Add the HasFilesTrait trait to all the Eloquent models that can own files.

  2. Run the migrations to add the fileables tables.

  3. Add these variables to .env file if you want to override the default values.
Variable Name Default Value
SF_FILESYSTEM_DISK config('filesystems.default')
SF_EXPIRE_AFTER 1 day
SF_PUBLIC_DIRECTORY public
SF_PRIVATE_DIRECTORY private

Usage

SimpleFiles

The package provides a service called helper functions:

  1. simpleFiles()
  2. simple_files()

Here's the list of its available methods.

Method Name Return Type Description
getFileSystemDisk string gets the filesystem disk
getDisk string shortcut for getFileSystemDisk method
getExpireAfterUnit string gets the time unit for temporary URL expiration
getExpireAfterValue string gets the time value for temporary URL expiration
getExpireAfter Illuminate\Support\Carbon gets the Carbon equivalent of getExpireAfterUnit() and getExpireAfterValue()
getPublicDirectory string gets the specified public directory
getPrivateDirectory string gets the specified private directory
shouldOverwriteOnExists bool decides whether to overwrite or not when it already exists
getFileSystemAdapter Illuminate\Contracts\Filesystem\Filesystem gets the filesystem adapter
getAdapter Illuminate\Contracts\Filesystem\Filesystem shortcut for getFileSystemAdapter method
getPublicAdapter Illuminate\Contracts\Filesystem\Filesystem uses getFileSystemAdapter method with $is_public to true
getPrivateAdapter Illuminate\Contracts\Filesystem\Filesystem uses getFileSystemAdapter method with $is_public to false
store Luchavez\SimpleFiles\Models\File or Collection or null stores file/s to specified public or private directory
storePublicly Luchavez\SimpleFiles\Models\File or Collection or null uses store() method with $is_public to true
storePrivately Luchavez\SimpleFiles\Models\File or Collection or null uses store() method with $is_public to false
getContentsFromURL string or null gets contents by using file_get_contents()
getContentsFromBase64 string or null gets contents by using base64_decode()
getFiles array gets files list from specified public or private directory
getPublicFiles array uses getFiles() method with $is_public to true
getPrivateFiles array uses getFiles() method with $is_public to false
getFile string or null gets file contents
getFilePublicly string or null uses getFile() method with $is_public to true
getFilePrivately string or null uses getFile() method with $is_public to false
putFile string or null uploads file to specified public or private directory
putFilePublicly string or null uses putFile() method with $is_public to true
putFilePrivately string or null uses putFile() method with $is_public to false
putFileAs string or null uploads file to specified public or private directory
putFilePubliclyAs string or null uses putFileAs() method with $is_public to true
putFilePrivatelyAs string or null uses putFileAs() method with $is_public to false
exists bool checks if file exists on specified public or private directory
existsPublicly bool uses exists() method with $is_public to true
existsPrivately bool uses exists() method with $is_public to false
delete bool deletes file/s from specified public or private directory
deletePublicly bool uses delete() method with $is_public to true
deletePrivately bool uses delete() method with $is_public to false
getDirectories array gets files list from specified public or private directory
getPublicDirectories array uses getDirectories() method with $is_public to true
getPrivateDirectories array uses getDirectories() method with $is_public to false
deleteFiles bool deletes files from specified public or private directory
deletePublicFiles bool uses deleteFiles() method with $is_public to true
deletePrivateFiles bool uses deleteFiles() method with $is_public to false
relateFileModelTo void dynamically build relationship from any model to the File model
generateUrl void create a new url or temporary url to a Luchavez\SimpleFiles\Models\File instance

HasFilesTrait

The package also provides HasFilesTrait which you can use on Eloquent models that you want to have files or images.

Here's the list of methods that will be added to Eloquent models.

Method Name Return Type Description
files Illuminate\Database\Eloquent\Relations\MorphToMany gets all files
images Illuminate\Database\Eloquent\Relations\MorphToMany gets all image files
nonImages Illuminate\Database\Eloquent\Relations\MorphToMany gets all non-image files
fileables Illuminate\Database\Eloquent\Relations\MorphMany gets all fileables
fileable Illuminate\Database\Eloquent\Relations\MorphOne gets latest fileable
imageables Illuminate\Database\Eloquent\Relations\MorphMany gets all imageables
imageable Illuminate\Database\Eloquent\Relations\MorphOne gets latest imageable
nonImageables Illuminate\Database\Eloquent\Relations\MorphMany gets all non-imageables
nonImageable Illuminate\Database\Eloquent\Relations\MorphOne gets latest non-imageable
attachFiles void attaches file/s to model
attachPublicFiles void attaches file/s to model
attachPrivateFiles void attaches file/s to model
syncFiles void syncs file/s to model
syncPublicFiles void syncs file/s to model
syncPrivateFiles void syncs file/s to model
detachFiles void detaches file/s to model
detachPublicFiles void detaches file/s to model
detachPrivateFiles void detaches file/s to model

Examples

Note: In case you did not specify the user who uploaded the file, it will try to get the authenticated user via auth()->user().

Here are the .env variables used in this example:

Uploading files

Let's start first by creating a public route /api/files. Use storePublicly() and storePrivately() methods of simpleFiles() global helper function to store the files on public/dev/dummy and private/dev/dummy directories respectively.

Once that is set up, we can use Postman to upload files to the route above.

Note: If you will open an expired url, you'll receive a Request has expired error.

Attaching files

To attach an uploaded file to a model, use the attachFiles() method from HasFilesTrait.

Change log

Please see the changelog for more information on what has changed recently.

Testing

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.


All versions of simple-files with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/support Version ~9|~10
luchavez/starter-kit Version ^1.0
ext-fileinfo Version *
league/flysystem-path-prefixing Version ^3.10
league/flysystem-read-only Version ^3.10
spatie/laravel-tags Version ^4.5
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 luchavez/simple-files contains the following files

Loading the files please wait ....