Download the PHP package magdev/console-form without Composer

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

Console Form

Build Status

A simple form solution when using the Symfony console component.

There are two ways forms can be created, one is using the standalone method which usually takes place in the command execute method.

Or by taking advantage of the auto discovery feature so you can reuse forms throughout the project, which keeps the form logic decoupled from the command it's executed on.

Getting Started

First, you'll need to download the console form library using composer:

Set the \Droath\ConsoleForm\FormHelper as a helper class within the console application HelperSet:

Auto Discovery

If you decide to use the auto discovery feature you'll need to use the \Droath\ConsoleForm\FormDiscovery class:

The \Droath\ConsoleForm\FormDiscovery::discover() method takes two arguments, the first argument is either a single directory or an array or directories. These directories are searched for form classes that have implemented the \Droath\ConsoleForm\FormInterface interface. The second argument is the class namespace.

Here is an example of what the form class needs to implement so it's found by the auto discovery feature:

Form Basics

Interacting with the form helper within the command class. Either you can create a form using the standalone method or retrieve the form using the name that was defined (auto discovery needs to be implemented).

First, I'll show you the standalone method on which you can create a form:

If using auto discovery you can simply just retrieve the form by name:

Form Save

Many of times forms need to save their results to a filesystem. The form save() method displays a confirmation message asking the user to save the results (which is configurable). If input is true, then the save callable is invoked; otherwise it's disregarded.

Form Field Groups

There might come a time when you need to group fields together. One of the advantages would be having the ability to collect multiple inputs for a grouping of fields. As you can see in the example below, the setLoopUntil() provides the result array that was last given, these values can help determine if you should stop collecting data. Return false to stop field group iteration, otherwise set to true.

Form Fields

There are three basic field types which are:

All field types derive from the base field class, so most fields have similar methods and features.

Below are some examples of the most useful field methods:

Condition

The setCondition() method allows a field to be shown based on what value was previously inputted by the user. This method can be set multiple times if you require more conditions to be met for a given field.

The "More options for 7.x version" text field will only be shown if the 7.x version was selected in the previous question.

Field Callback

The setFieldCallback() method requires a single callback function, which can be any valid PHP callable. The callback will be invoked during the form process lifecycle. The field callback receives two arguments, the first argument is the field instance. The second is an array of results for all previous questions.

Now you can set additional methods for a given field instance based on the results for a previous question(s). As you can see in the example below the select options are added based on the results retrieved from the "Project Name" text field.

Subform

The setSubform() method requires a callback function to be set, which can be an anonymous function or any valid PHP callable. The subform function is invoked during the original form process lifecycle.

The subform callable is given two arguments, the first argument is the subform instance and the second is the inputed value. The callable doesn't need to return any data. Also, the original form process takes care of processing the subform.


All versions of console-form with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
symfony/console Version ^2.8 || ^3.0
symfony/finder Version ^2.8 || ^3.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 magdev/console-form contains the following files

Loading the files please wait ....