Download the PHP package alirezajavadi/jsonize without Composer

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

JSONize

Tests PHP Version

A fluent PHP library for building standardized JSON API responses.

Requirements

Installation

Quick Start

JSONize provides two usage modes: Easy (static, zero-boilerplate) and Efficient (singleton, memory-safe for long-running processes).

Easy Mode

Output:

In Easy mode, the response is automatically sent when the object is destroyed. Call ->get() instead if you need the JSON string returned without echoing:

Efficient Mode

Efficient mode uses a singleton so you reuse the same instance. Always call ->get() to retrieve the JSON string.

API Reference

All methods are chainable and available in both modes.

message(string $message)

Sets the response message.

status(int $code, string $message = "")

Sets the HTTP status code. Optionally pass a custom status message to override the default.

data(mixed $data, string $key = "data")

Sets the response payload. The second argument changes the JSON key name.

With a custom key, the output uses that key instead of "data":

error(string $message, int $status = 500)

Shorthand for setting an error message and status code in one call.

headers(array $headers)

Merges custom HTTP headers into the response. CORS headers are included by default.

hideStatus() / hideMessage() / hideData() / hideSuccess()

Remove specific fields from the JSON output.

get()

Returns the JSON string and prevents automatic output (Easy mode). In Efficient mode, this is the only way to get the response.

Full Examples

Success with data:

Validation error:

Minimal response:

Supported HTTP Status Codes

All standard HTTP status codes (1xx through 5xx) are supported with their official reason phrases. Custom status messages can be provided via ->status($code, "Your message").

Testing

Tests run automatically via GitHub Actions on every push to main/develop and on pull requests, across PHP 8.1 through 8.4.

To run locally:

Contributing

Contributions are welcome. Please submit a pull request or open an issue for bugs and suggestions. Follow Conventional Commits for commit messages.

License

MIT — see LICENSE for details.

Author

Alireza Javadi


All versions of jsonize with dependencies

PHP Build Version
Package Version
No informations.
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 alirezajavadi/jsonize contains the following files

Loading the files please wait ...