Download the PHP package ccuffs/poll-from-text without Composer
On this page you can find all versions of the php package ccuffs/poll-from-text. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package poll-from-text
Introduction
poll-from-text
is a PHP package to parse semi-structured text into structured-data that can be used to build questionnaires (forms). The main goal is to allow end users to build dynamic forms, e.g. Google Forms, using plain text like they would if the forms were to be printed on paper.
NOTICE: this package assumes a certain format in the "pure" text, so it might not be as generic as possible. The world has bigger problems.
✨Features
- Simple input questions (useful to create
<input type="text" />
elements); - Question with options (useful to create
<select>
elements); - Options with no value (only text), e.g.
- Text
, or* Text
(like in<option>Text</option>
); - Options with a value, e.g
a) Text
(value is"a"
, like in<option value="a">Text</option>
); - Data attributes (as JSON objects) for both questions and options, e.g.
{"type":"file"} What?
(useful to create custom form elements such as<input type="file" />
).
🚀 Getting started
1. Add this package to your project
At the root of your project, run:
2. Basic usage
Instantiate the class CCUFFS\Text\PollFromText
then call parse()
:
Tip: use
CCUFFS\Text\PollFromText::make()
if you don't want to instantiate an object.
The output should be something like:
A new line (without the option marks) indicates a new question:
The output should be something like:
You can create questions with options by prefixing lines with -
or *
:
The output should be something like:
3. Advanced usage
You can create questions with options and their values by using )
, for instance:
The output should be something like:
Both questions and options accept a json string as a data field, e.g.
The output should be something like:
Data attribute for an options:
The output should be something like:
3.1 Specific configuration
Both parse()
and make()
accept a $config
which is an array of configuration to consider when generating the questionnaire. Below is a complete list of all available configuration options:
4. Testing (related to the package development)
If you plan on changing how the package works, be sure to clone it first:
Install dependencies
Make your changes. After, run the tests it to ensure nothing breaked:
There should be plenty of green marks all over 😁
🤝 Contribute
Your help is most welcome regardless of form! Check out the code of conduct before making any interaction with other community members.
See the ROADMAP.md file for an idea of how the project should evolve.
🎫 License
This project is licensed under the MIT open-source license and is available for free.
🧬 Changelog
See all changes to this project in the CHANGELOG.md file.
🧪 Similar projects
Below is a list of interesting links and similar projects: