Download the PHP package plumthedev/json-shape without Composer

On this page you can find all versions of the php package plumthedev/json-shape. 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 json-shape

JsonShape

Your Laravel JSON columns deserve types. JsonShape turns an untyped JSON column into a real, typed object — with autocomplete, static analysis, and methods — without giving up the array you already know.

Latest Version Total Downloads PHP Version

The 2am problem

You reach for a JSON column because the data is structured but doesn't deserve its own table — user preferences, an API response you cached, audit context, a feature-flag payload. It works. Then six months later:

Eloquent hands JSON columns back as a plain array. That means no autocomplete, no static analysis, and no guarantees. The structure lives only in your head and in a migration comment nobody reads. Every access is a leap of faith — was it email or emails? is theme always set? did that last deployment change the shape? — and the answer arrives in production, as an undefined array key deep inside a controller.

You've been compensating with accessors, data_get() calls, defensive ?? chains, and json_decode sprinkled across your models. It's noise, and it still doesn't make the data typed.

Meet JsonShape

Describe the structure once, as a class. From then on, Eloquent hands you a typed object instead of a bare array — and your IDE and PHPStan finally understand what's inside your JSON.

Same column. Same database. The only thing that changed: the mistakes you used to ship now fail in your editor and your CI, before a user ever hits them.

Before and after

Plain array cast With JsonShape
Misspelled key breaks at runtime caught by PHPStan
Autocomplete none every field
Missing/optional fields silent null or fatal typed, explicit
Reading the shape scroll to the migration read the class
Behaves like an array yes still yes

"Why not just use an array?"

The honest answer to the most common objection:

Where teams use it

JsonShape pays off anywhere a JSON column has a knowable shape that's read in more than one place:

Quick start

Requires PHP 8.4+ and Laravel 13.

1. Describe the shape. The @phpstan-type block is the single source of truth; expose values as typed property hooks or getters.

2. Cast it on the model.

3. Use it like an object.

Need a generic, untyped shape? Cast with AsJsonShape::class and you'll get a plain JsonShape back — still array-accessible, just without a dedicated class.

When to use it — and when not to

Reach for JsonShape when:

Skip it when:

We'd rather you not install it than fight it. If your case is in the "skip" column, the docs say so plainly.

Documentation

Full guides and runnable examples live at plumthedev.github.io/json-shape — a set of short, progressive chapters:

  1. Define a shape
  2. Read values
  3. Write values
  4. Cast it on a model
  5. Create & combine shapes
  6. Type safety in depth
  7. Helpers, macros & errors

The bigger idea

Laravel gave us first-class casts, property hooks, and a strong static-analysis story with Larastan. Typed JSON columns are the obvious next step — and there's no agreed-on, ergonomic way to do it yet. JsonShape is an opinionated attempt to define that pattern: types that PHPStan enforces, an object that still feels like the array underneath, and as little machinery as possible in between.

It's early, and the conventions are still being shaped — which is exactly why your input matters. If you have a strong opinion about how typed JSON in Laravel should feel, this is a great time to help set the direction.

Contributing

Contributions, issues, and ideas are all welcome. Open an issue to discuss a change or challenge a design decision, or send a pull request.

The whole toolchain runs in Docker, so all you need locally is Docker (with the Compose plugin) and Make:

The default PHP version is 8.4; override it per command with PHP_VERSION (82, 83, 84), e.g. make phpunit PHP_VERSION=83.

License

Released under the MIT License.


All versions of json-shape with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
illuminate/contracts Version ^13.16
illuminate/database Version ^13.16
illuminate/support Version ^13.16
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 plumthedev/json-shape contains the following files

Loading the files please wait ...