Download the PHP package lsbproject/request-bundle without Composer

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

LSBProjectRequestBundle

SymfonyInsight \ Request bundle created to represent request data as a strict objects.

Installation

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

Usage

Create a request class and extend AbstractRequest:

That's all. This will require foo_bar parameter to be present in request, query, cookie, head or attribute (All types you can find in RequestStorage). \ Then use it in controller:

Using objects

Also this bundle supports loading objects like you usually do with @ParamConverter. All ParamConverts will be performed to the property.

If you are not using PHP 7.4, you can point the class with annotations @var or @PropConverter (attributes also available right now with the same annotation class)

(Be aware that you need to specify full classname with a namespace)

Configuring property

As you could notice there is a useful annotation @PropConverter which is in fact is an adapter to @ParamConverter of sensio-framework-bundle. Be free to modify any of parameters, as they are working in the same way as in the original one.

Request storage

By default all parameters from body, request, headers, cookies or path will be used. \ To restrict parameter to be located in exact place you can use @RequestStorage annotation

From example above you will get foo_baz parameter from request body or path, and foo_bar parameter exactly from request body. \ There are 5 types of storage: query, body, path, cookie and header.

Validation

You can use symfony/validation to validate parameters in request. Install component and use it as usual

Using mutators

To specify property you also can use setters instead of public properties to add some additional logic.

Working with entities

There is an annotation @Entity which is almost equal to the sensio annotation.

Use mapping property to point aliases from the request to the original parameters names.

Custom naming conversion

By default all properties will be converter to snake_case style. You can change this behaviour by creating a class which implements LSBProject\RequestBundle\Util\NamingConversion\NamingConversionInterface

then you should register it as a service and point it out in the bundle configuration.

You can also apply your conversion to the separate object or its part. Just register your conversion as a service and point its name in RequestStorage::converter

Using DTOs as property

There is also a possibility to specify deeper nested level in the request. To do it, specify special option of PropConverter::isDto for class property. This will prevent standart ParamConverter to be applied and will recursively perform AbstractRequest converter to the object.

Using Collections

To specify an array of objects which should be converted, use isCollection property or use typehinting. You can use it in combination \ with isDto to specify array of objects to be set. \ Be aware that it's not recommended to use collection for entities as it's very inefficient way of getting data as it \ will perform request to DB.

Using discriminator field

Sometimes we do not know which object will be returned. To resolve this discriminator mechanism appears in game.

Correspondingly to field field in Discriminator attribute object will be configured accordingly to mapping.

Use on a custom objects

There is also possibility to apply LSB converter to the object not inheriting AbstractRequest. You can use @LSB\Request annotation to point out parameter in controller.

Examples

More examples you can find here

Writing documentation

OpenApi: https://github.com/22116/request-doc-bundle

Known issues


All versions of request-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
ext-json Version *
symfony/framework-bundle Version ^3 || ^4 || ^5 || ^6
sensio/framework-extra-bundle Version ^3 || ^4 || ^5 || ^6
symfony/property-info Version ^3 || ^4 || ^5 || ^6
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 lsbproject/request-bundle contains the following files

Loading the files please wait ....