Download the PHP package ed-fruty/strange-observer without Composer

On this page you can find all versions of the php package ed-fruty/strange-observer. 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 strange-observer

Strange PHP observer (JFF)

Sometimes we need to listen class calling actions, but for example we haven't permissions to edit it.

Sometimes we have some instance of class only and we can't extend this class. (For example Database class. Instance was created and if we try to create new extend instance - new connection will be created. Or class can be final etc.)

But functional of this class does not satisfy to our needs.

For such cases you can use this strange observer ;)

Installation

Install package via composer

Usage

For example we have class User with method register($attributes) and we want to add listeners for this method

All done! We can use $user as previously

Ok, now we want to add validation before register

And we want to send email when registration was successfull

Now we can use

and before regitration will execute validaion, and after - sending email.

We can set priorities to the listeners

Also, we can bind new methods dynamically to the $user

We can redefine existing methods

As you can see, in the code we uses 3 types of calling methods

  1. $user->method()
  2. $user()->method()
  3. $user(true)->method()

    • $user is instanece of Invoker class and call $user->method() remap to the real instance of User class and can be listened
    • $user(true) is real instance of User, calling $user(true)->method() can not be listened
    • $user() is instance of observer to adding new listeners, binding new methods So, when you bind method

    We can add subscriber to the $user calls

    How to check instance ?

    
    
    if ($user instanceof User === true) {
    // Fail. $user is instance of Fruty\Observe\Invoker
    }
    
    if ($user(true) instanceof User) {
    // Success
    }

All versions of strange-observer 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 ed-fruty/strange-observer contains the following files

Loading the files please wait ....