Download the PHP package edram/laravel-temp-workspace without Composer

On this page you can find all versions of the php package edram/laravel-temp-workspace. 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-temp-workspace

Laravel Temp Workspace

English · 简体中文

Temporary, isolated workspaces backed by Laravel Storage, with automatic cleanup at the end of a request, command, or queue job attempt.

Contents

Requirements

Dependency Supported versions
PHP 8.3+
Laravel 12.45+ within 12.x, or 13.x

Installation

Laravel discovers the service provider automatically. Configuration is optional; workspaces use Laravel's default filesystem disk and the temporary-workspaces directory.

Basic usage

Use create() to get an isolated temporary directory and work with it through Laravel Storage methods:

Manual deletion is optional. At the end of the request, command, or queue job attempt, the package automatically removes the workspace directory and its contents.

Usage

Approach Use it when
Named workspace The work is reusable and has its own input or lifecycle hooks.
Anonymous workspace A closure is enough for a small, one-off operation.
Temporary directory You want to manage the work yourself and use temporary storage.

Named workspaces

Create a class in app/TempWorkspaces. Put input values in the constructor and declare service dependencies on handle(), like a Laravel job or command.

For example, download a file and return its MD5 checksum:

Perform it through the manager:

The handle() return value is the result. Each instance has a stable ID that can be read before execution, and can only be prepared once. Create a new instance for each execution or retry.

Anonymous workspaces

Closures can receive both the current workspace and other container dependencies:

Temporary directory only

Use create() when you want to perform file operations directly:

Automatic cleanup also applies to workspaces created this way.

Storage and configuration

Optionally publish config/laravel-temp-workspace.php:

The disk defaults to null, so Laravel Storage resolves filesystems.default (configured by Laravel's FILESYSTEM_DISK). Set a workspace disk only when it should differ from the application's default.

Config key Environment variable Default
disk TEMP_WORKSPACE_DISK null — follow filesystems.default
directory TEMP_WORKSPACE_DIRECTORY temporary-workspaces

Optional environment overrides:

Leave TEMP_WORKSPACE_DISK unset to follow Laravel's default disk. directory is relative to the disk; it is not an absolute filesystem path.

Each workspace is stored at temporary-workspaces/{id} relative to the selected disk. Workspace disks use Laravel's scoped driver and preserve the parent disk's prefix and options. Storage::fake() is supported for testing.

TempWorkspace forwards filesystem methods to its isolated disk. Access the underlying Laravel FilesystemAdapter through $workspace->disk().

On a local disk, path() returns a local filesystem path. On a remote disk, it returns a storage path; use get(), readStream(), or checksum() to process the file through Storage. URL methods depend on the selected driver's capabilities.

Preserve outputs before cleanup. If your result refers to a temporary file, copy or stream it to permanent storage before the workspace's lifecycle ends.

Lifecycle and cleanup

Context Cleanup happens
HTTP request During application termination, after the response is sent.
Artisan command When the command finishes, including ordinary exceptions.
Queue job After each attempt, including the job's failure handler.

Nested command and job scopes clean their own workspaces, preserving those owned by the enclosing lifecycle. perform() itself does not trigger cleanup.

Cleanup relies on Laravel reaching its lifecycle events. Forced process termination and worker timeouts may leave files behind.

Named hooks

Add these methods to a named workspace as needed:

failed() receives the exception thrown by handle(). terminate() runs at cleanup before the directory is deleted, so it can still access the files and release additional resources. Dependencies on terminate() are container-resolved.

Terminating callbacks

Register additional cleanup from within your work or on a created workspace:

Callbacks run through the container after terminate() and before directory deletion. A failing hook does not prevent remaining hooks or cleanup from running. Hook and directory cleanup errors are reported through Laravel's exception handler. If failed() throws, the original work exception is still rethrown.

Manual cleanup

Call $workspace->destroy() to delete a single workspace's directory and contents immediately. It returns a boolean and only deletes files; lifecycle hooks still run when the manager cleans up, so those hooks should not rely on deleted files.

For long-running work, consume or persist the results, then explicitly clean all workspaces currently tracked by the manager:

Cleanup affects every scope tracked by that manager. Repeated calls without new workspaces do not rerun the completed cleanup hooks.

API reference

API Purpose
$manager->create() Create and prepare a temporary workspace.
$manager->perform($work) Synchronously execute a workspace instance or closure and return its result.
$manager->cleanup() Clean every workspace currently tracked by the manager.
$workspace->id() Get the stable ID of this instance.
$workspace->disk() Access its prepared Laravel filesystem adapter.
$workspace->destroy() Delete this workspace's directory and contents immediately.
$workspace->terminating($callback) Register a callback to run before directory deletion.
$workspace->put(), get(), path(), … Call the corresponding Laravel filesystem method.

Resolve WorkspaceManager through the container, or call create(), perform(), and cleanup() through the LaravelTempWorkspace facade.

Development

Tests use Pest and Orchestra Testbench, including HTTP, Artisan, and synchronous and database queue lifecycle coverage.

License

MIT. See LICENSE.md.


All versions of laravel-temp-workspace with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/console Version ^12.45 || ^13.0
illuminate/contracts Version ^12.45 || ^13.0
illuminate/filesystem Version ^12.45 || ^13.0
illuminate/queue Version ^12.45 || ^13.0
illuminate/support Version ^12.45 || ^13.0
league/flysystem-path-prefixing Version ^3.0
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 edram/laravel-temp-workspace contains the following files

Loading the files please wait ...