Download the PHP package mellivora/laravel-api-caster without Composer

On this page you can find all versions of the php package mellivora/laravel-api-caster. 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-api-caster

Laravel API Caster

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Convert API response results to Entity objects like Laravel Eloquent. This package provides a powerful and flexible way to transform API responses into structured, type-safe entities with support for casting, mapping, data transformation, and enhanced collection handling with metadata support.

Features

Requirements

Installation

You can install the package via composer:

Quick Start

Basic Usage

Collections

Advanced Usage

Type Casting

Entity Mapping

Field Configuration

Custom Casters

Available Cast Types

Type Description Example
int, integer Cast to integer '123' โ†’ 123
float, double, real Cast to float '12.34' โ†’ 12.34
string Cast to string 123 โ†’ '123'
bool, boolean Cast to boolean 1 โ†’ true
array Cast JSON to array '[1,2,3]' โ†’ [1,2,3]
json Alias for array Same as array
object Cast JSON to object '{"a":1}' โ†’ stdClass
collection Cast to Collection [1,2,3] โ†’ Collection
date Cast to Carbon date '2023-01-01' โ†’ Carbon
datetime Cast to Carbon datetime '2023-01-01 12:00:00' โ†’ Carbon
timestamp Cast timestamp to Carbon 1672574400 โ†’ Carbon
decimal:2 Cast to decimal string 12.345 โ†’ '12.35'
date:Y-m-d Custom date format Custom format
datetime:Y-m-d H:i Custom datetime format Custom format

Testing

Code Quality

API Documentation

Entity Class

Methods

Response Class

Methods

Caster Class

Methods

Best Practices

  1. Use Type Hints: Always define proper types in your entity classes
  2. Leverage Caching: Cache frequently used entities to improve performance
  3. Validate Data: Use Laravel's validation before creating entities
  4. Handle Nulls: Always consider null values in your casting logic
  5. Test Thoroughly: Write tests for your custom entities and casters

Performance Tips

Troubleshooting

Common Issues

Issue: "Class not found" error when using custom casters Solution: Ensure your caster class implements the Castable interface

Issue: Infinite recursion with circular references Solution: Use excludes to break circular references

Issue: Memory issues with large datasets Solution: Process data in chunks using collections

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-api-caster with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3|^8.4
brick/math Version ^0.10|^0.11|^0.12
nesbot/carbon Version ^2.0|^3.0
illuminate/contracts Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.0
psr/http-message Version ^2.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 mellivora/laravel-api-caster contains the following files

Loading the files please wait ...