Download the PHP package a7-tech/laminas-attribute-controller without Composer

On this page you can find all versions of the php package a7-tech/laminas-attribute-controller. 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 laminas-attribute-controller

Laminas Attribute Controller

Description

This package provides attribute-based controllers for use in Laminas applications. It simplifies route management, dependency injection, and input handling in controller arguments.

Installation

Requirements

Instructions

  1. Install the package:

  2. Set up the module in your Laminas application by adding it to the application.config.php:

Usage

Example Controller with Attributes

Route Registration

Routes are automatically registered through attributes when the module is enabled.

Attributes Documentation

Route

The Route attribute defines routing for controller methods.

Parameters:

QueryParam

The QueryParam attribute extracts and validates query parameters from the request.

Parameters:

Autowire

The Autowire attribute enables automatic dependency injection.

Parameters:

IsGranted

The IsGranted attribute provides auth-based access control for controller methods.

Parameters:

MapRequestPayload

The MapRequestPayload attribute maps the request body to a parameter.

This attribute automatically deserializes the request body into the specified type.

Example with Multiple Fields and Validators

Using this DTO with the MapRequestPayload attribute will automatically validate all fields according to the specified constraints.

MapQueryString

The MapQueryString attribute maps the query string parameters to a typed object.

This attribute automatically deserializes the query string parameters into the specified type, making it easy to work with structured query parameters in GET requests.

Example with Multiple Fields and Validators

Using this DTO with the MapQueryString attribute will automatically validate all query parameters according to the specified constraints. This example would handle a query like ?searchTerm=john&limit=50&page=2&sortDirection=desc.

CurrentUser

The CurrentUser attribute injects the current authenticated user into a parameter. For implementation, you need to have a user entity and a service that retrieves the current user from the session or security context implemented LaminasAttributeController\Security\GetCurrentUser

This attribute provides easy access to the authenticated user without manual retrieval.

Advanced Configuration

Custom Resolvers

The package allows you to create and configure your own parameter resolvers. This is useful when you need custom logic for resolving controller action parameters.

To create a custom resolver:

  1. Create a class that implements ParameterResolverInterface:

  2. Register your resolver in the configuration:

The order of resolvers in the configuration is important as they are tried in sequence until one returns a non-null value.

Default Resolvers

The package comes with the following default resolvers:

You can customize which resolvers are used by modifying the configuration:


All versions of laminas-attribute-controller with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laminas/laminas-mvc Version ^3.0
beberlei/assert Version ^3.3
doctrine/orm Version ^2.0 | ^3.0
jms/serializer Version ^3.30
symfony/validator Version ^5.4 | ^6.0 | ^7.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 a7-tech/laminas-attribute-controller contains the following files

Loading the files please wait ....