Download the PHP package php-deal/framework without Composer

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

PhpDeal

Design by Contract framework for PHP

What is Design by Contract?

The specification of a class or interface is the collection of non-private items provided as services to the caller, along with instructions for their use, as stated in phpDoc. Design By Contract is an effective technology for creating a specification.

The fundamental idea of Design By Contract is to treat the services offered by a class or interface as a contract between the class (or interface) and its caller. Here, the word "contract" is meant to convey a kind of formal, unambiguous agreement between two parties:

If the caller fulfills the requirements, then the class promises to deliver some well-defined service. Some changes to a specification/contract will break the caller, and some won't. For determining if a change will break a caller, C++ FAQs uses the memorable phrase "require no more, promise no less": if the new specification does not require more from the caller than before, and if it does not promise to deliver less than before, then the new specification is compatible with the old, and will not break the caller.

Build Status GitHub release Code Coverage Scrutinizer Code Quality Minimum PHP Version License

Installation

PhpDeal framework can be installed with composer. Installation is quite easy, just ask composer to download the framework with its dependencies by running the command:

Setup

Put the following code at the beginning of your application entry point or require it from an external file.

Symfony setup

Put the following code in app_dev.php and adapt it to match your folder structure. The appDir must point to the folder containing the src files, not the document root folder !

Pre and Post Contracts

The pre contracts specify the preconditions (requirements) before a statement is executed. The most typical use of this would be in validating the parameters to a function. The post contracts (promises) validate the result of the statement. The most typical use of this would be in validating the return value of a method and of any side effects it has. The syntax is:

By definition, if a pre contract fails, then the body received bad parameters. A ContractViolation exception is thrown. If a post contract fails, then there is a bug in the body. A ContractViolation exception is thrown.

Invariants

Invariants are used to specify characteristics of a class that always must be true (except while executing a protected or private member function).

The invariant is a contract saying that the asserts must hold true. The invariant is checked when a class constructor completes and at the end of the class public methods:

Invariants contain assert expressions, and so when they fail, they throw a ContractViolation exception.

NOTE: The code in the invariant may not call any public non-static members of the class, either directly or indirectly. Doing so will result in a stack overflow, as the invariant will wind up being called in an infinitely recursive manner.

Contract propagation

There a some differences in inheritance of the contracts:

  1. Ensure
    • if provided Ensure will automatically inherit all contracts from parent class or interface
  2. Verify
    • if provided Verify will not inherit contracts from parent class or interface
    • to inherit contracts you will need to provide @inheritdoc or the Inherit contract
  3. Invariant
    • if provided Invariant will inherit all contracts from parent class or interface
  4. Inherit
    • if provided Inherit will inherit all contracts from the given level (class, method) without the need to provide a contract on your current class or method

Notes:

Foo::bar accepts 2 literal as a parameter and does not accept 1.

With @inheritdoc:

Foo::bar does not accept 1 and 2 literals as a parameter.

For postconditions (Ensure and Invariants contracts) subclasses inherit contracts and they don't need @inheritdoc. Example:

Foo::setBar does not accept 1 and 2 literals as a parameter.

If you don't want to provide a contract on your curent method/class you can use the Inherit annotation:

Foo:bar() does accept eveything, except: 2

Integration with assertion library

To enhance capabilities of contracts, it's possible to use assertion library.

More assertions

IDE Integration

To improve your productivity with PhpStorm, you should definitely install a Go! AOP Framework plugin (>=1.0.1) to have a PHP syntax highlighting for defining contracts and navigation to AOP advices.

PhpStorm example

Common issues

Fatal error: Uncaught Error: Class 'Go\ParserReflection\Instrument\PathResolver'

This happens if your appDir configuration points at the same level as your vendor directory. To solve this issue try adding your vendor folder into the excludePaths configuration.


All versions of framework with dependencies

PHP Build Version
Package Version
Requires php Version ~7.1
goaop/framework Version ^2.3
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 php-deal/framework contains the following files

Loading the files please wait ....