Download the PHP package alpa/tools_proxy_object without Composer

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

Dev work plan

install

composer require alpa/tools_proxy_object:1.0.14

Changes

Description

A proxy object is an object that implements all the available magic methods that run the corresponding handlers. These handlers perform a number of custom actions on the target object.
Basically, this behavior is necessary for processing the result when accessing properties or methods of the target object.
In simple words:

The component creates a proxy object for the observed object or class.
Action handlers (get | set | call | isset | unset | invoke | toString | iterator) are assigned for each member of the observable object or class .
A similar principle is implemented in javascript through the Proxy constructor.
When accessing a member of an object, through the proxy object, the assigned handler for the specific action will be invoked.

Where the component can be applied:

Note

1

From version 1.0.0 to version 1.1.0 is experimental development, where the API will be subject to modification.
See the tag description on GitHub for version compatibility.
When including a component in a project, specify a specific version.
The description of the api for a specific version can be found in the commit version.

2

If for some reason you have bugs or other problems, then it is recommended to implement your own handlers classes that fix this problem. See - Creating handler classes

3

The proxy object is a wrapper object that implements magic methods. By default it is not possible to access protected / private members of an observable object / class. The default proxy only works with the public members of the observable / class. If you need the ability to work with protected / private members of an object / class, use Reflector classes in action handlers.

4

Not the fact that the use of proxy objects will be fast. But in any case, this is the optimal solution for creating complex combinations and in a simple way.

Install

composer require alpa/tools_proxy_object

Getting started

example 1:

example 2:

example 3:

example 4 -

Definitions

Definitions:

Create handlers for Proxy object

There are two ways to write handlers:

There are two types of handlers:

If action handler is no assigned to a member, then an action handler for all members is applied.
If action handler is no assigned to members, then standard actions will be applied.

The following actions exist when accessing the members of an object:

Dynamic writing of handlers through closure functions

Example in the constructor

Handlers can be assigned outside of the constructor.
An example of assigning handlers via the Handlers :: init method

An example of assigning handlers for a specific property

or

Static writing of handlers through class declaration.

Class declaration in which methods will be handlers.

or

or

You can declare the following instance methods as handlers (when inheriting classes Alpa\ProxyObject\Handlers\StaticActions or Alpa\ProxyObject\Handlers\InstanceActions or Alpa\ProxyObject\Handlers\Instance) :

You can declare the following static methods as handlers : (when inheriting class Alpa\ProxyObject\Handlers\Instance)

A templates for creating action handlers for all members of an object.

Template where static actions and actions for an instance are declared

Template where only instance actions

Template where only static actions

Action handlers for a specific member are created similar to action handlers for all properties. The exceptions are the "invoke"? "toString" and "iterator" actions. they only apply to the observable object or class.

Example:

Proxying class static members

In addition to proxying the members of an object, it is possible to proxy static members of a class. To do this, instead of an object, you will need to specify the class

Creating handler classes

The constructor of the Alpa \ ProxyObject \ Proxy class can accept as handlers any object or class that implements the Alpa \ ProxyObject \ Handlers \ ActionsInterface interface.

For each action (set | get | isset | unset | call | invoke | toString | iterator) you will need to implement working code.

If for some reason you have bugs or other problems, then it is recommended to implement your own handlers classes that fix this problem.

Other Proxy Class

(v>=1.0.11) When creating a proxy object by handlers, you can specify which proxy class to use

Difficulties

For a member of a proxy object, it doesn't make sense to apply checks such as property_exists ormethod_exists or similar, since they will be applied directly to the proxy object. Therefore, when working with a proxy, always use the isset check. If you have complex logic where you need to check both properties and methods, then it is recommended to separate the logic for working with properties and the logic for working with methods.


All versions of tools_proxy_object with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4||^8
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 alpa/tools_proxy_object contains the following files

Loading the files please wait ....