Download the PHP package folded/request without Composer
On this page you can find all versions of the php package folded/request. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download folded/request
More information about folded/request
Files in folded/request
Package request
Short Description Request utilities, including a request validator, for your PHP web app.
License MIT
Informations about the package request
folded/request
Request utilities, including a request validator, for your PHP web app.
Summary
- About
- Features
- Requirements
- Installation
- Examples
- Version support
About
I need a way to pull a simple library to validate my request data when a form is submited. This library hopefuly solves this by faciliting the set up to be ready to validate request values.
Folded is a constellation of packages to help you setting up a web app easily, using ready to plug in packages.
- folded/action: A way to organize your controllers for your web app.
- folded/config: Configuration and environment utilities for your PHP web app.
- folded/crypt: Encrypt and decrypt strings for your web app.
- folded/exception: Various kind of exception to throw for your web app.
- folded/history: Manipulate the browser history for your web app.
- folded/http: HTTP utilities for your web app.
- folded/orm: An ORM for you web app.
- folded/routing: Routing functions for your PHP web app.
- folded/session: Session functions for your web app.
- folded/view: View utilities for your PHP web app.
Features
- Can get GET or POST request data
- Can check if a key is present in GET or POST data
- Can validate request (using Laravel's validation request utilities)
- Can check if the request validation succeeded
- Can get the (translated) errors when the request validation failed
Requirements
- PHP version >= 7.4.0
- Composer installed
Installation
- 1. Install the package
- 2. Set up the library
1. Install the package
In your root folder directory, run this command:
2. Set up the library
If you want to use the request validation functions, use this code before validating your form data:
The lang folder should contain an arborescence made of folders named with the lang (like "en", "fr", "es", ...), which themselves contain a file named validation.php
containing the translation of the validation error message.
As this library relies on Laravel's validation system, the validation errors messages are pulled from these files.
Here is the content of en/validation.php
for example. You can start from this file to create translation for other languages.
Examples
- 1. Get a request value by its key
- 2. Check if a request key is present
- 3. Get all the request values
- 4. Validate a request
- 5. Check if a request validation succeeded
- 6. Get error messages after a request validation
- 7. Choosing the validation error language before validating request
- 8. Get an old submited form value
1. Get a request value by its key
In this example, we will get the value of a request key after a post request has been submitted.
2. Check if a request key is present
In this example, we will check first if a key is present before echoing its content.
3. Get all the request values
In this example, we will get all the request value key-pairs in an array.
4. Validate a request
In this example, we will validate form request data.
For more information about the available validation, check Laravel's validation documentation, as this library relies on this system.
5. Check if a request validation succeeded
In this example, we will check if a request succeeded after validating it.
6. Get error messages after a request validation
In this example, we will get the errors messages of a failed request validation.
For more information about how to manipulate the errors, see Laravel's validation error documentation, as this library relies on this system.
7. Choosing the validation error language before validating request
In this example, before validating the request, we will change the language for the validation erorrs. Note that you should do it ideally right after the code from the Installation section: 2. Set up the library section.
8. Get an old submited form value
In this example, we will get a previously submitted form value. This is convenient if you want to display values the user used before an error occured (in order for the user to not loose everything he wrote).
If the key is not found, the getOldRequestValue()
function returns null
.
Version support
7.3 | 7.4 | 8.0 | |
---|---|---|---|
v0.1.0 | ❌ | ✔️ | ❓ |
v0.2.0 | ❌ | ✔️ | ❓ |
v0.3.0 | ❌ | ✔️ | ❓ |
v0.3.1 | ❌ | ✔️ | ❓ |
v0.3.2 | ❌ | ✔️ | ❓ |
v0.3.3 | ❌ | ✔️ | ❓ |
All versions of request with dependencies
illuminate/http Version 7.*
illuminate/validation Version 7.*
folded/exception Version 0.4.*