Skip to main content
Laravel Data provides Artisan commands to streamline development and optimize production performance.

make:data

Generate new data objects quickly.

Basic Usage

Creates App\Data\PostData in the app/Data directory.

Custom Namespace

Change the namespace:
Creates App\DataTransferObjects\PostData in app/DataTransferObjects.

Options

Examples

Configuration

Customize default behavior in config/data.php:

Custom Stub

Publish and customize the stub file:
Edit the stub at stubs/data.stub:

data:cache-structures

Cache data object analysis for production performance.

Basic Usage

Output:

Show Cached Classes

Display which classes were cached:
Output:

When to Run

Run this command:
  1. Before deploying to production
  2. After creating new data objects
  3. After modifying existing data objects
  4. As part of your deployment script

Deployment Script Example

Error Handling

If caching is disabled in config:
Output:
Enable it in config/data.php:

Clear Cache

Clear the data structures cache:
Or clear only data structures (if using a separate cache store):
The cache key prefix is configurable in config/data.php under structure_caching.cache.prefix.