Download the PHP package laragear/json without Composer

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

JSON Transport

Latest Version on Packagist Latest stable test run Codecov coverage Maintainability Sonarcloud Status Laravel Octane Compatibility

Easily retrieve and manipulate Json across your application.

Become a sponsor

Your support allows me to keep this package free, up-to-date and maintainable. Alternatively, you can spread the word!.

Requirements

Installation

Fire up Composer and require this package in your project.

composer require laragear/json

That's it.

Why is this for?

If you feel cumbersome to build complex JSON responses, or to deal with JSON trees values back and forth, this package is for you. It comes with a lot of features to make not only building and manipulating JSON trees.

From the HTTP Request

Simply use getJson() to automatically retrieve all the JSON from the request, or a given key value.

[!TIP]

You can still use the json() method to retrieve the JSON data as a ParameterBag or a key value.

As an HTTP Response

You can build a Json instance using make(), optionally with your own array, but you can also use anything that implements the Arrayable contract or is iterable. Since the Json instance implements the Responsable trait, you can return it as-is and will be automatically transformed into a JSON response.

You can also transform it into a response and modify the outgoing response parameters, like the header or the status.

Creating an instance

If you already have the array you want to transform into JSON, use the make() method or just instantiate it manually. Either way is fine. You can also use Arrayable objects and anything that is iterable, like Collections.

If the value is already a JSON string, use fromJson().

Available methods

The Json instance contains multiple helpful methods to make dealing with JSON data a breeze:

Method Description
get($key, $default = null) Retrieves a key value in "dot" notation, returning a default value if its not set.
getMany([$key => $value], $default = null) Retrieves an array of values keyed "dot" notation, filling a default value on those not set.
set($key, $value, $overwrite = true) Sets a key in "dot" notation with a value.
setMany([$key => $value], $overwrite = true) Sets multiple keys in "dot" notation with their respective values.
fill($key, $value) Sets a key in "dot" notation with a value if the key doesn't exists or is null.
fillMany([$key => $value]) Sets multiple keys in "dot" notation with their respective values if they don't exist.
has($key) Check if a key in "dot" notation is defined in the JSON.
hasAny(...$keys) Check if at least one of the keys in "dot" notation is defined in the JSON.
missing($key) Check if a key in "dot" notation is not defined in the JSON.
forget($key) Removes (forgets) a key in "dot" notation from the JSON.
unset($key) Removes (forgets) a key in "dot" notation from the JSON.
isSet($key) Check if a key in "dot" notation exists and is not null.
isNotSet($key) Check if a key in "dot" notation doesn't exists or is not null.
isEmpty() Check if the JSON data is empty.
isNotEmpty() Check if the JSON data is not empty.
keys() Returns an array of all the root-level keys of the JSON.
only(...$keys) Returns an array of only the issued root-level keys of the JSON.
except(...$keys) Returns an array of all the root-level keys of the JSON except those issued.
segments($keys, $default = null) Returns a Json instance a segment of the JSON data using keys in "dot" notation.
collect($key = null) Returns a Collection instance from the JSON data, or value of a key in "dot" notation.
make($value = []) Creates a new Json instance from an iterable or Arrayablevalue.
wrap($value) Returns a Json instance from an iterable or Arrayable value if it's not Json.
fromJson($string) Returns a Json instance from a JSON-encoded string.

Eloquent JSON Cast

When dealing with JSON attributes in models, you will note that is really cumbersome to work with. Instead of using arrays or Collections, you can use the AsJson and AsEncryptedJson casts, that will offer a Json instance from the model property as-is or encrypted into the database, respectively.

Just add one of these to your model casts.

Once done, you can easily fill JSON into your model like normal.

PhpStorm stubs

For users of PhpStorm, there is a stub file to aid in macro autocompletion for this package. You can publish them using the phpstorm tag:

The file gets published into the .stubs folder of your project. You should point your PhpStorm to these stubs.

Laravel Octane compatibility

There should be no problems using this package with Laravel Octane.

Security

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

License

This specific package version is licensed under the terms of the MIT License, at time of publishing.

Laravel is a Trademark of Taylor Otwell. Copyright © 2011-2025 Laravel LLC.


All versions of json with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version 11.*|12.*
illuminate/http Version 11.*|12.*
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 laragear/json contains the following files

Loading the files please wait ....