Download the PHP package ixbox/moonlight without Composer

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

Moonlight

English | 日本語

A small PHP library for adding Set-Cookie headers to PSR-7 responses.

PSR-7 has no type for cookies, so you have to build each Set-Cookie string yourself and add it line by line with withAddedHeader(). Moonlight lets you build cookies as objects and attach them all with a single presentTo() call.

The name comes from Moonlight, a cookie made by the Japanese confectioner Morinaga. The class names follow the same pastry-shop theme:

Class Role
Patisserie A cookie factory that holds shared attributes. bake() makes a cookie
Cookie A single cookie. Casting it to string gives the Set-Cookie value
GiftBox A box of cookies. presentTo() gives them to a response

Requirements

Installation

Usage

You can also create a Cookie directly:

Cookie and Patisserie are immutable. Each with*() method returns a modified copy and leaves the original unchanged.

Deleting a cookie

expire() returns a copy with an empty value and an expiry date in the past. A browser deletes a cookie only when its name, Path, and Domain all match, so the safest way is to bake it from the same Patisserie you created it with and then call expire():

Options

Key Type with* method Description
expires int withExpires() Expiry as a Unix timestamp. 0 or omitted means a session cookie (same as setcookie())
path string withPath() Path attribute
domain string withDomain() Domain attribute
secure bool withSecure() Secure attribute
httponly bool withHttpOnly() HttpOnly attribute
samesite 'Lax'\|'Strict'\|'None' withSameSite() SameSite attribute. Omitted from the output when not set (browsers then treat it as Lax)
partitioned bool withPartitioned() Partitioned attribute (CHIPS)

When expires is set, Moonlight also outputs Max-Age, the number of seconds remaining at the time the cookie is converted to a string.

Browsers reject SameSite=None and Partitioned without Secure. Set secure to true when you use them.

Validation

Invalid values throw InvalidArgumentException. Validation does not use assert(), so it also runs in production.

Cookie values are encoded with rawurlencode() (a space becomes %20), so both PHP's $_COOKIE and JavaScript's decodeURIComponent() can decode them.

GiftBox

GiftBox stores cookies by name. Putting in a cookie with the same name replaces the earlier one.

presentTo() adds one Set-Cookie line per cookie and keeps any existing Set-Cookie headers.

Development

License

MIT


All versions of moonlight with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
psr/http-message Version ^1.0|^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 ixbox/moonlight contains the following files

Loading the files please wait ...