Download the PHP package szogyenyid/php-builder without Composer

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

PHP Builder

A PHP trait to automagically create a Builder with fluent interface for any class.


Why PHP Builder?

Builder is a creational design pattern, which allows constructing complex objects step by step. The intent of the builder design pattern is to separate the construction of a complex object from its representation. It is one of the Gang of Four design patterns.

As PHP does not support inner classes (like Java does), if you would like to create builders, you have to write a new class for every one you want to use a builder with, and maintain them when the base class changes. By using PHP Builder you do not need to create separate builder classes in your namespace.

PHP Builder may help preventing some bugs, as variables are only accessed once, when instantiating them with the property values already set. Alse, there is no need to write any public setters, which would make the class mutable or vulnerable. Before calling the build() method, no instance is accessible, after calling it, no properties can be changed from outside the instance (unless they are public, or have a public setter).

Instead of this, written without PHP Builder:

You have to write this if using PHP Builder:

In the first case, you have to write public setters, which make your class mutable after creation. In the second case, there are no setters, and the properties are private, so there is no chance they will change after creation.

It can also increase the legibility of your code, as you get a fluent interface, and can get rid of the repetition of the variable name.

Installation

Installation is the easiest via Composer:

or add it by hand to your composer.json file.

Upgrading

PHP Builder follows semantic versioning, which means breaking changes may occur between major releases. As the current highest version is V1, you do not need to worry about versions at this moment.

Usage

To automagically gain access to a builder, all you need to do is adding the trait to your class:

There are no rules for your class to follow to use Builder, no setters or public properties are necessary.

The above example is a 100% valid class to use Builder with.

Having this provides access to the builder, like the following:

All of the builder's methods will follow the names of the properties prepending with. For more legibility, you can change the first letter of the property to capital (instead of withname, you can use withName).

Possible errors

If Builder encounters any error, a BuilderException will be thrown.

If you call a builder method (except build() and reset()) that does not start with with, an exception with the following message is thrown:

If a property with the corresponding name is not found, the following message will be sent with a BuilderException:

License

PHP Builder is licensed under MIT License.


All versions of php-builder with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 szogyenyid/php-builder contains the following files

Loading the files please wait ....