Download the PHP package joe.szeto/capsule without Composer

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

Install

Basic usage

we can use attribute to tell the code the following Closure is a setter, and the value of the setter is the return value of the closure

we can also use method to set the value of the setter

Auto resolve params

if the closure has type hints and the type hint is the same as the value of the setter, the value will be resolved automatically even if the params name is not 100% match, it will still work

we can resolve parameters by the application container leverages the underlying container's reflection capabilities. This means that when a closure or callable object is executed, the Capsule library can automatically inject the required dependencies as defined by the type hints of the parameters.

OnBlank

it will only call when the value of the setter is null

we can also use attribute to set and detect the OnBlank at the same time

we can also use method to set the OnBlank

Closure

if the set value is a closure, when the type hint of the param of using is Closure the original closure will be passed to the param

when the type hint of the params is a NOT closure, the value will be return

Evaluable

if the type is closure, and call it we have to pass the params manually

but if we pass the param one by one manually it will be very tedious now Evaluable become handy

Each

for each value, the closure will be called

Only

Skip

Mocking

The Capsule::mock method allows developers to replace parts of their application's behavior with predetermined responses or operations. This is particularly useful in testing, where you want to isolate the part of the application you are testing and control its interactions with external dependencies.

To replace a string value within the capsule, simply pass the key and the new string value to the mock method.

If you need to mock the behavior of a function, provide a closure as the second argument. This closure will be executed in place of the original function associated with the given key.

To mock an object, pass an instance of the class as the second argument. This instance will replace any existing instances bound to the specified key within the capsule.

Mock with sequence

Catch

Namespace

it can resolve params from namespace, capsules under same namespace can share the value

Append

append function will append the callable to the end of the capsule

use append combined with namespace

massage

when we want to change the value of some variable we will always do something like the following

so I come up with the idea of massage

or

but if we want to use this approach, we have to follow some conventions

=

and the must be the key of the data

for example

this is equivalent to


All versions of capsule with dependencies

PHP Build Version
Package Version
Requires laravel/framework Version ^10 || ^11.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 joe.szeto/capsule contains the following files

Loading the files please wait ....