Download the PHP package doekenorg/decorate-php without Composer

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

Decorate PHP

Easily create decorators and proxies with a simple (composer) command.


Do you enjoy using decorators in PHP, but hate having to implement one with large amounts of methods? Then this is the plugin for you! You can now quickly create a (final or abstract) class from an interface with all the methods already implemented and forwarded to the next instance. This little time saver lets you get on with the things you enjoy.

Installation

Notice: This is a global plugin, so don't forget global in the command!

Usage

The plugin adds a decorate command to your composer instance. It needs a source class (the interface you want to decorate) and a target class. You can optionally provide the name of the variable it uses for the next class. Currently, the plugin only works for composer projects.

Create a new decorator

This will create, and write, a file called DestinationClass.php in the appropriate folder mapped in your psr-4 autoloader configuration.

A file like this will be created:

Create a new decorator with a specific variable name.

By default, the decorated instance is mapped to a variable called $next. You can overwrite this by providing it as the third parameter. In the next example the variable will be called $client.

Here the output will be something like:

Note: The command will not overwrite an existing file. Provide the --overwrite option to force write.

Options

The command comes with the following options:

Global configuration

You can use the following configuration in the extra key of your global composer.json (usually in ~/.composer).

Other information

PSR-4 only

Writing files is only supported for PSR-4 namespaces provided in the autoload key of your project. No PSR-0 support.

No decorating final classes

Obviously, you cannot create a decorator for a final class.

Decorating abstract classes

Although not common, you can also decorate abstract classes. In this case, any final methods are ignored when creating the decorator.

(Decorating non-abstract classes isn't really useful; but I kept the possibility for the extenders among us.)

Constructors

When an abstract class or interface declares a __construct method; it will append the next instance as the first argument. In case of an abstract class, it will also call the parent::__construct() method with the appropriate arguments.

Caveats


All versions of decorate-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
composer-plugin-api Version ^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 doekenorg/decorate-php contains the following files

Loading the files please wait ....