Download the PHP package lisachenko/scalar-objects without Composer

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

๐ŸŽ Scalar Objects

Methods on strings, ints, floats, bools and arrays. In pure PHP.

For over a decade, "methods on scalars" has been one of PHP's most-wished-for features. nikic/scalar_objects proved it was possible โ€” with a C extension you had to compile, ship, and rebuild for every PHP version. This package delivers the same idea as a composer require: no C toolchain, no custom PHP build, no opcode handlers. Just PHP convincing its own compiler to do the work.

โœจ Why this approach is interesting

The trick is when the magic happens. Instead of intercepting every method call at runtime, this package teaches the compiler a new trick, once per file, through z-engine โ€” the library that opens the Zend Engine to userland PHP via FFI. At compile time, a zend_ast_process hook rewrites every method-call node in the syntax tree:

box() is ordinary PHP: objects pass through untouched, scalars get wrapped in the handler registered for their type, and dispatch on the wrapper is plain VM dispatch with warm inline caches. That one design decision buys properties a runtime hook could never offer:

C extension / opcode hooks AST rewrite (this package)
Install compile against each PHP build composer require
Call-time cost C handler on every INIT_METHOD_CALL one PHP function call (~0.25 ยตs), zero FFI
Undefined method on "str" engine-level error paths catchable BadMethodCallException
Call on an unregistered type engine-level error paths the VM's own catchable Error
Custom handlers rebuild the extension Registry::register() at runtime
Coverage per-opcode special cases literals, variables, chains, ?->, dynamic names, spread, named args, (...) โ€” uniformly, because it is just syntax

All the FFI work happens once per file at compile time; the code your application actually executes is code the PHP VM was built to run fast.

Curious how deep the engine access goes? z-engine's tour of the API covers the AST hooks used here, plus operator overloading, runtime class specialization, and more โ€” this package is one worked example of what that toolbox makes possible.

๐Ÿ“œ The contract

๐Ÿงฐ Registering handlers

Defaults ship for string, int, float, bool and array and are registered by the bootstrap. null is deliberately left out โ€” opt in if you want it:

The type system is yours to shape: custom handlers extend Lisachenko\ScalarObjects\TypeHandler and replace the shipped ones at call time โ€” registration is ordinary runtime code, no recompilation involved:

๐Ÿšช Gating the rewrite

Every method call in a rewritten file โ€” object receivers included โ€” pays the small box() detour. The rewriter never touches vendor/ or its own sources; for production keep the gate tight:

โฑ The compile-order rule

Only code compiled after the hook is installed gets the rewrite. Composer's files autoload installs it before your application code compiles, which covers the common case; under opcache remember that op_arrays compiled before the hook existed (or before a gate change) are served as-is until invalidated โ€” use opcache.preload or invalidate after deploys.

๐Ÿ“‹ Requirements

z-engine now ships stable tags for both supported minors, so installing it needs no stability configuration at all. scalar-objects itself is not tagged yet, so ask for it by branch โ€” an explicit dev-main constraint carries its own stability flag and still needs no root minimum-stability:

๐Ÿงช Testing

For a one-off run without touching php.ini:

๐Ÿ“š See also

License

MIT


All versions of scalar-objects with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
ext-ffi Version *
lisachenko/z-engine Version ~8.4.2 || ~8.5.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 lisachenko/scalar-objects contains the following files

Loading the files please wait ...