### GET /ping with HTML Accept Header Source: https://api-tools.getlaminas.org/documentation/intro/getting-started Demonstrates a GET request to the /ping endpoint requesting HTML, which results in a 406 Not Acceptable error. ```APIDOC ## GET /ping with HTML Accept Header ### Description This endpoint tests the RPC service by making a GET request and specifying an 'Accept: text/html' header. ### Method GET ### Endpoint /ping ### Parameters #### Headers - **Accept** (string) - Required - Specifies the desired response media type, in this case, 'text/html'. ### Request Example ``` GET /ping HTTP/1.1 Accept: text/html ``` ### Response #### Error Response (406) - **detail** (string) - Description of the error, indicating the Accept type cannot be honored. - **status** (integer) - The HTTP status code (406). - **title** (string) - The title of the error response ('Not Acceptable'). - **type** (string) - A URI identifying the error type. #### Response Example ```json { "detail": "Cannot honor Accept type specified", "status": 406, "title": "Not Acceptable", "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html" } ``` ``` -------------------------------- ### GET /ping with JSON Accept Header Source: https://api-tools.getlaminas.org/documentation/intro/getting-started Demonstrates a successful GET request to the /ping endpoint requesting JSON, which returns a 200 OK with a JSON payload. ```APIDOC ## GET /ping with JSON Accept Header ### Description This endpoint tests the RPC service by making a GET request and specifying an 'Accept: application/json' header for a successful JSON response. ### Method GET ### Endpoint /ping ### Parameters #### Headers - **Accept** (string) - Required - Specifies the desired response media type, in this case, 'application/json'. ### Request Example ``` GET /ping HTTP/1.1 Accept: application/json ``` ### Response #### Success Response (200) - **ack** (integer) - An acknowledgment value, typically a timestamp. #### Response Example ```json { "ack": 1396560875 } ``` ``` -------------------------------- ### Install Laminas API Tools via Composer Source: https://api-tools.getlaminas.org/documentation/intro/installation Installs the Laminas API Tools skeleton project using the Composer create-project command. This is the recommended method for starting a new project. ```bash composer create-project laminas-api-tools/api-tools-skeleton path/to/install ``` -------------------------------- ### OPTIONS /ping Request Source: https://api-tools.getlaminas.org/documentation/intro/getting-started Demonstrates an OPTIONS request to the /ping endpoint to retrieve allowed HTTP methods. ```APIDOC ## OPTIONS /ping Request ### Description This endpoint demonstrates an OPTIONS request to the /ping endpoint, which is used to query the server for the HTTP methods it supports. ### Method OPTIONS ### Endpoint /ping ### Response #### Success Response (200) - **Allow** (string) - Response header indicating the methods allowed for this endpoint (e.g., 'GET'). #### Response Example ``` HTTP/1.1 200 OK Allow: GET ``` ``` -------------------------------- ### GET Request for JSON (Successful) Source: https://api-tools.getlaminas.org/documentation/intro/getting-started Shows a successful GET request to the service, requesting JSON, which returns a 200 OK status with JSON data. ```http GET /ping HTTP/1.1 Accept: application/json ``` ```http HTTP/1.1 200 OK Content-Type: application/json { "ack": 1396560875 } ``` -------------------------------- ### GET Request for HTML (Not Acceptable) Source: https://api-tools.getlaminas.org/documentation/intro/getting-started Demonstrates a GET request to the service specifying 'text/html' in the Accept header, which results in a 406 Not Acceptable error. ```http GET /ping HTTP/1.1 Accept: text/html ``` ```http HTTP/1.1 406 Not Acceptable Content-Type: application/problem+json { "detail": "Cannot honor Accept type specified", "status": 406, "title": "Not Acceptable", "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html" } ``` -------------------------------- ### POST /ping Request Source: https://api-tools.getlaminas.org/documentation/intro/getting-started Demonstrates a POST request to the /ping endpoint with a JSON payload, which is not allowed by default. ```APIDOC ## POST /ping Request ### Description This endpoint demonstrates a POST request to the /ping endpoint with a JSON content type and payload. API Tools, by default, only allows GET requests for this endpoint, resulting in a 405 Method Not Allowed error. ### Method POST ### Endpoint /ping ### Parameters #### Headers - **Accept** (string) - Required - Specifies the desired response media type, in this case, 'application/json'. - **Content-Type** (string) - Required - Specifies the media type of the request body, 'application/json'. #### Request Body - **timestamp** (integer) - Required - A timestamp value. ### Request Example ```json { "timestamp": 1396560875 } ``` ### Response #### Error Response (405) - **Allow** (string) - Response header indicating the methods allowed for this endpoint (e.g., 'GET'). #### Response Example ``` HTTP/1.1 405 Method Not Allowed Allow: GET ``` ``` -------------------------------- ### OPTIONS Request for Allowed Methods Source: https://api-tools.getlaminas.org/documentation/intro/getting-started Demonstrates using the OPTIONS request method to inquire about the supported HTTP methods for a given service endpoint, which responds with the allowed methods. ```http OPTIONS /ping HTTP/1.1 ``` ```http HTTP/1.1 200 OK Allow: GET ``` -------------------------------- ### POST Request to RPC Service Source: https://api-tools.getlaminas.org/documentation/intro/getting-started Illustrates a POST request to the service with a JSON payload, which is not allowed by default, resulting in a 405 Method Not Allowed error. ```http POST /ping HTTP/1.1 Accept: application/json Content-Type: application/json { "timestamp": 1396560875 } ``` ```http HTTP/1.1 405 Method Not Allowed Allow: GET ``` -------------------------------- ### Install Laminas API Tools Welcome Module Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-welcome Installs the laminas-api-tools/api-tools-welcome package using Composer. ```bash $ composer require laminas-api-tools/api-tools-welcome ``` -------------------------------- ### Example public/.gitignore entries Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-asset-manager Example of entries added to a public/.gitignore file by the asset manager plugin to ignore installed asset directories. This prevents them from being committed to version control by default. ```gitignore # public/.gitignore api-tools/ api-tools-welcome/ ``` -------------------------------- ### Install HybridAuth using Composer Source: https://api-tools.getlaminas.org/documentation/recipes/integrate-social-logins This command installs the HybridAuth library, which is used for authentication with third-party providers. ```bash $ composer require hybridauth/hybridauth:dev-3.0.0-Remake ``` -------------------------------- ### Enable Development Mode and Run Built-in Server Source: https://api-tools.getlaminas.org/documentation/intro/installation Enables development mode for Laminas API Tools and starts the built-in PHP web server. This is intended for development environments only. It configures the server to listen on 0.0.0.0:8080, disables error display for cleaner API responses, and points the document root to the `public` directory. ```bash cd path/to/install composer development-enable php -S 0.0.0.0:8080 -ddisplay_errors=0 -t public public/index.php ``` -------------------------------- ### Install laminas-api-tools/api-tools-content-negotiation via Composer Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-content-negotiation Installs the content negotiation module using the Composer package manager. ```bash $ composer require laminas-api-tools/api-tools-content-negotiation ``` -------------------------------- ### Install laminas-api-tools/api-tools-configuration via Composer Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-configuration This command installs the api-tools-configuration module using Composer. Ensure you have Composer installed and configured for your project. ```bash $ composer require laminas-api-tools/api-tools-configuration ``` -------------------------------- ### REST Configuration Example Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-rest Example of user configuration for a REST resource, specifying listener, route, HTTP methods, and entity/collection classes. ```APIDOC ## REST Configuration Example ### Description This is an example of how a user might configure a REST resource within an application. It specifies the controller listener, route details, supported HTTP methods for collections and entities, and the classes used for entity and collection representation. ### Configuration Snippet ```php 'AddressBook\V1\Rest\Contact\Controller' => [ 'listener' => 'AddressBook\V1\Rest\Contact\ContactResource', 'route_name' => 'address-book.rest.contact', 'route_identifier_name' => 'contact_id', 'collection_name' => 'contact', 'entity_http_methods' => [ 0 => 'GET', 1 => 'PATCH', 2 => 'PUT', 3 => 'DELETE', ], 'collection_http_methods' => [ 0 => 'GET', 1 => 'POST', ], 'collection_query_whitelist' => [], 'page_size' => 25, 'page_size_param' => null, 'entity_class' => 'AddressBook\V1\Rest\Contact\ContactEntity', 'collection_class' => 'AddressBook\V1\Rest\Contact\ContactCollection', 'service_name' => 'Contact', ] ``` ### Key Configuration Options - **`listener`**: The listener class responsible for handling REST resource logic. - **`route_name`**: The name of the route associated with this resource. - **`route_identifier_name`**: The name of the route parameter used as the entity identifier. - **`collection_name`**: The name of the resource collection. - **`entity_http_methods`**: An array of HTTP methods supported for individual resource entities. - **`collection_http_methods`**: An array of HTTP methods supported for the resource collection. - **`page_size`**: The default number of items to return per page for collections. - **`entity_class`**: The class used for representing a single resource entity. - **`collection_class`**: The class used for representing a collection of resource entities. ``` -------------------------------- ### OPTIONS Request Example Source: https://api-tools.getlaminas.org/documentation/api-primer/http-negotiation Demonstrates an example OPTIONS request made to an API endpoint to determine allowed HTTP methods. ```http OPTIONS /api/user HTTP/1.1 Host: example.org ``` -------------------------------- ### Install Laminas API Tools Swagger Adapter with Composer Source: https://api-tools.getlaminas.org/documentation/api-doc/swagger This command installs the necessary package for enabling Swagger documentation in Laminas API Tools. It requires Composer to be installed. ```bash $ composer require laminas-api-tools/api-tools-documentation-swagger ``` -------------------------------- ### Install API Blueprint Provider via Composer Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-documentation-apiblueprint Installs the laminas-api-tools/api-tools-documentation-apiblueprint package using the Composer dependency manager. ```bash $ composer require laminas-api-tools/api-tools-documentation-apiblueprint ``` -------------------------------- ### Clone Laminas API Tools Repository and Install Dependencies Source: https://api-tools.getlaminas.org/documentation/intro/installation Clones the Laminas API Tools skeleton project from GitHub and installs its dependencies using Composer. This method is useful for developers who want to work directly with the repository. ```bash git clone https://github.com/laminas-api-tools/api-tools-skeleton.git # optionally, specify the directory in which to clone cd path/to/install composer install ``` -------------------------------- ### Implement RPC Service Controller in PHP Source: https://api-tools.getlaminas.org/documentation/intro/getting-started This snippet shows how to implement the `pingAction` method in a PHP controller for an RPC service. It utilizes `LaminasMvcControllerAbstractActionController` and `LaminasApiToolsContentNegotiationViewModel` to return data with the current timestamp. ```php namespace Status\V1\Rpc\Ping; use Laminas\Mvc\Controller\AbstractActionController; use Laminas\ApiTools\ContentNegotiation\ViewModel; class PingController extends AbstractActionController { public function pingAction() { return new ViewModel([ 'ack' => time() ]); } } ``` -------------------------------- ### Custom Header Versioning Examples Source: https://api-tools.getlaminas.org/documentation/api-primer/versioning Shows examples of using custom HTTP headers to specify the API version. ```text X-API-Version: 2 GData-Version: 2.0 X-MS-Version: 2011-08-18 ``` -------------------------------- ### Install laminas-api-tools/api-tools-rpc via Composer Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-rpc Installs the laminas-api-tools/api-tools-rpc package using Composer. This is the recommended way to add the module to your project. ```bash $ composer require laminas-api-tools/api-tools-rpc ``` -------------------------------- ### Install Laminas API Tools Dependencies via Composer Source: https://api-tools.getlaminas.org/documentation/recipes/api-tools-in-an-existing-laminas-mvc-application Installs the core Laminas API Tools package and development-time tools using Composer. Ensure you have Composer installed. ```bash $ composer require "laminas-api-tools/api-tools:~1.0" $ composer require --dev "laminas-api-tools/api-tools-admin:~1.0" $ composer require --dev "laminas/laminas-development-mode:~2.0" ``` -------------------------------- ### Laminas HAL Module Installation Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-hal Instructions for installing the Laminas HAL module using Composer. ```APIDOC ## Composer Installation ### Description Install the Laminas HAL module using the Composer package manager. ### Method Composer CLI ### Endpoint N/A ### Parameters N/A ### Request Example ```bash $ composer require laminas-api-tools/api-tools-hal ``` Alternatively, add to `composer.json`: ```json { "require": { "laminas-api-tools/api-tools-hal": "^1.4" } } ``` Then run `composer update`. ### Configuration Add the module to your `config/application.config.php`: ```php return [ /* ... */ 'modules' => [ /* ... */ 'Laminas\ApiTools\Hal', ], /* ... */ ]; ``` If using `laminas-component-installer`, the module will be installed automatically. ``` -------------------------------- ### Install api-tools-asset-manager Plugin Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-admin Installs the api-tools-asset-manager Composer plugin and performs necessary steps to ensure it picks up assets. ```bash composer require --dev laminas-api-tools/api-tools-asset-manager rm -Rf ./vendor composer install ``` -------------------------------- ### Install Laminas API Tools Documentation with Composer Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-documentation This command installs the Laminas API Tools documentation module using Composer, a dependency manager for PHP. It fetches the package and makes it available for use in the project. ```bash $ composer require laminas-api-tools/api-tools-documentation ``` -------------------------------- ### API Tools System Configuration Example Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-mvc-auth A system configuration snippet for `config/module.config.php` demonstrating the setup of aliases and factories for authentication and authorization services within API Tools. ```php 'service_manager' => [ 'aliases' => [ 'authentication' => 'Laminas\ApiTools\MvcAuth\Authentication', 'authorization' => 'Laminas\ApiTools\MvcAuth\Authorization\AuthorizationInterface', 'Laminas\ApiTools\MvcAuth\Authorization\AuthorizationInterface' => 'Laminas\ApiTools\MvcAuth\Authorization\AclAuthorization', ], 'factories' => [ 'Laminas\ApiTools\MvcAuth\Authentication' => 'Laminas\ApiTools\MvcAuth\Factory\AuthenticationServiceFactory', 'Laminas\ApiTools\MvcAuth\ApacheResolver' => 'Laminas\ApiTools\MvcAuth\Factory\ApacheResolverFactory', 'Laminas\ApiTools\MvcAuth\FileResolver' => 'Laminas\ApiTools\MvcAuth\Factory\FileResolverFactory', 'Laminas\ApiTools\MvcAuth\Authentication\DefaultAuthenticationListener' => 'Laminas\ApiTools\MvcAuth\Factory\DefaultAuthenticationListenerFactory', 'Laminas\ApiTools\MvcAuth\Authentication\AuthHttpAdapter' => 'Laminas\ApiTools\MvcAuth\Factory\DefaultAuthHttpAdapterFactory', 'Laminas\ApiTools\MvcAuth\Authorization\AclAuthorization' => 'Laminas\ApiTools\MvcAuth\Factory\AclAuthorizationFactory', 'Laminas\ApiTools\MvcAuth\Authorization\DefaultAuthorizationListener' => 'Laminas\ApiTools\MvcAuth\Factory\DefaultAuthorizationListenerFactory', 'Laminas\ApiTools\MvcAuth\Authorization\DefaultResourceResolverListener' => 'Laminas\ApiTools\MvcAuth\Factory\DefaultResourceResolverListenerFactory', ], 'invokables' => [ 'Laminas\ApiTools\MvcAuth\Authentication\DefaultAuthenticationPostListener' => 'Laminas\ApiTools\MvcAuth\Authentication\DefaultAuthenticationPostListener', 'Laminas\ApiTools\MvcAuth\Authorization\DefaultAuthorizationPostListener' => 'Laminas\ApiTools\MvcAuth\Authorization\DefaultAuthorizationPostListener', ], ], ``` -------------------------------- ### Composer Install (No Dev Dependencies) Source: https://api-tools.getlaminas.org/documentation/deployment/intro Installs Composer dependencies, omitting development packages. It also prioritizes distribution packages and optimizes the autoloader for production. ```bash $ php composer.phar install --no-dev --prefer-dist --optimize-autoloader ``` -------------------------------- ### Install laminas-api-tools/api-tools-api-problem via Composer Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-api-problem This snippet shows how to install the laminas-api-tools/api-tools-api-problem package using Composer. ```bash $ composer require laminas-api-tools/api-tools-api-problem ``` -------------------------------- ### Install Laminas API Tools OAuth2 via Composer Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-oauth2 Installs the laminas-api-tools/api-tools-oauth2 package using Composer. This command fetches the package and its dependencies. ```bash $ composer require laminas-api-tools/api-tools-oauth2 ``` -------------------------------- ### Install MongoDB Compatibility Package Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-oauth2 Installs the alcaeus/mongo-php-adapter package, which is required if you are using the ext/mongodb extension with this module. ```bash $ composer require alcaeus/mongo-php-adapter ``` -------------------------------- ### Install Laminas API Tools Provider via Composer Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-provider Instructions for installing the laminas-api-tools/api-tools-provider package using Composer. This command adds the package as a project dependency. ```bash $ composer require laminas-api-tools/api-tools-provider ``` -------------------------------- ### Install api-tools-asset-manager Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-asset-manager Command to install the api-tools-asset-manager composer plugin. This is typically used as a development dependency. ```bash composer require --dev laminas-api-tools/api-tools-asset-manager ``` -------------------------------- ### Bcrypt Hash Output Example Source: https://api-tools.getlaminas.org/documentation/auth/authentication-oauth2 Provides an example of the output generated by the bcrypt hashing utility, showing the resulting hash string. ```text $2y$10$8gHQy/sn0vB8H5wbAbhUi.tbUfpf6aE7PBllKHeKaCYTqEyd7vjo6 ``` -------------------------------- ### Install api-tools-doctrine Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-doctrine Instructions on how to install the laminas-api-tools/api-tools-doctrine module using Composer. ```APIDOC ## Install api-tools-doctrine Installation of this module uses composer. For composer documentation, please refer to getcomposer.org. ```bash $ composer require laminas-api-tools/api-tools-doctrine ``` If you use laminas-component-installer, that plugin will install api-tools-doctrine, and all modules it depends on, as a module in your application configuration for you. ``` -------------------------------- ### Install Laminas API Tools Admin Module Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-admin Installs the laminas-api-tools/api-tools-admin module as a development dependency using Composer. ```bash $ composer require --dev "laminas-api-tools/api-tools-admin" ``` -------------------------------- ### Install api-tools-doctrine Module Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-doctrine Installs the laminas-api-tools/api-tools-doctrine package using Composer. This command fetches the package and its dependencies, preparing them for use in a Laminas project. ```bash composer require laminas-api-tools/api-tools-doctrine ``` -------------------------------- ### Install Laminas MVC Auth via Composer Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-mvc-auth This snippet shows how to install the api-tools-mvc-auth module using Composer. ```bash $ composer require "laminas-api-tools/api-tools-mvc-auth" ``` -------------------------------- ### Install zf-console using Composer Source: https://api-tools.getlaminas.org/documentation/modules/zf-console Installs the zf-console component using the Composer package manager. This command adds the zf-console dependency to your project. ```bash $ composer require zfcampus/zf-console ``` -------------------------------- ### Install Laminas API Tools via Composer Source: https://api-tools.getlaminas.org/documentation/modules/api-tools Installs the Laminas API Tools package using Composer. This command adds the package as a dependency to your project. ```bash $ composer require laminas-api-tools/api-tools ``` -------------------------------- ### Install Laminas API Tools REST using Composer Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-rest Installs the laminas-api-tools/api-tools-rest package via Composer, a common method for managing PHP dependencies. ```bash $ composer require laminas-api-tools/api-tools-rest ``` -------------------------------- ### Install api-tools-versioning using Composer Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-versioning This command installs the api-tools-versioning module using Composer, a dependency manager for PHP. It adds the package to your project's requirements. ```bash $ composer require laminas-api-tools/api-tools-versioning ``` -------------------------------- ### Example GET Request for Filtering and Ordering Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-doctrine-querybuilder This example demonstrates how a GET request can be structured to include filtering and ordering parameters. It specifies an equality filter on the 'name' field and orders results by the 'startAt' field in descending order. ```php $_GET = [ 'filter' => [ [ 'type' => 'eq', 'field' => 'name', 'value' => 'Tom', ], ], 'order-by' => [ [ 'type' => 'field', 'field' => 'startAt', 'direction' => 'desc', ], ], ]; ``` -------------------------------- ### Install Laminas HAL via Composer Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-hal This snippet shows how to install the laminas-api-tools/api-tools-hal package using Composer. It also covers updating dependencies and enabling the module in the application configuration. ```bash $ composer require laminas-api-tools/api-tools-hal ``` ```json { "require": { "laminas-api-tools/api-tools-hal": "^1.4" } } ``` ```php return [ /* ... */ 'modules' => [ /* ... */ 'Laminas\ApiTools\Hal', ], /* ... */ ]; ``` -------------------------------- ### Create and Run a ZF Console Application Source: https://api-tools.getlaminas.org/documentation/modules/zf-console Provides a complete example of setting up and running a ZF Console application. It includes initializing the dispatcher, mapping commands like 'self-update' and 'build' to their respective callables, instantiating the Application, and running it. ```php use My\SelfUpdate; use Zend\Console\Console; use ZF\Console\Application; use ZF\Console\Dispatcher; require_once __DIR__ . '/vendor/autoload.php'; // Composer autoloader define('VERSION', '1.1.3'); $dispatcher = new Dispatcher(); $dispatcher->map('self-update', new SelfUpdate($version)); $dispatcher->map('build', 'My\Build'); $application = new Application( 'Builder', VERSION, include __DIR__ . '/config/routes.php', Console::getInstance(), $dispatcher ); $exit = $application->run(); exit($exit); ``` -------------------------------- ### GET /api/authentication Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-admin Retrieve the application's authentication configuration. ```APIDOC ## GET /api/authentication ### Description This REST endpoint retrieves the current authentication configuration for your application. ### Method GET ### Endpoint /api/authentication ### Response #### Success Response (200) - **Body**: An authentication resource representing the current settings. #### Error Response (404) - Returned if no authentication has been previously set up. ### Errors - `application/problem+json` ``` -------------------------------- ### Require laminas-api-tools/statuslib-example Module Source: https://api-tools.getlaminas.org/documentation/intro/first-rest-service This command uses Composer to install the statuslib-example module for Laminas API Tools. It's a prerequisite for following the tutorial. ```bash $ composer require laminas-api-tools/statuslib-example ``` -------------------------------- ### POST /api/authentication Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-admin Create the application's authentication configuration. ```APIDOC ## POST /api/authentication ### Description This REST endpoint is used to create the authentication configuration for your application. ### Method POST ### Endpoint /api/authentication ### Parameters #### Headers - **Content-Type**: `application/json` ### Request Body - **Body**: An authentication resource containing all necessary details for creating new HTTP authentication. ### Request Example ```json { "authentication": { "type": "basic", "realm": "API Realm" } } ``` #### Success Response (201) - **Body**: The created authentication resource. ### Errors - `application/problem+json` ``` -------------------------------- ### GET /foo - Unauthenticated Request Source: https://api-tools.getlaminas.org/documentation/auth/authentication-http-digest Example of a failed authentication attempt for HTTP Digest. ```APIDOC ## GET /foo - Failed Authentication ### Description This demonstrates a client making a request to the `/foo` endpoint with an invalid or missing HTTP Digest `Authorization` header, resulting in a 401 Unauthorized response. ### Method GET ### Endpoint /foo ### Parameters #### Query Parameters None #### Request Body None #### Headers - **Accept**: `application/json` - **Authorization**: `Digest clearly-invalid-token` ### Request Example ```http GET /foo HTTP/1.1 Accept: application/json Authorization: Digest clearly-invalid-token ``` ### Response #### Error Response (401) - **type** (string) - URI identifying the error type. - **title** (string) - A short, human-readable summary of the problem. - **status** (integer) - The HTTP status code. - **detail** (string) - A human-readable explanation specific to this occurrence of the problem. #### Response Example ```http HTTP/1.1 401 Unauthorized Content-Type: application/problem+json { "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html", "title": "Unauthorized", "status": 401, "detail": "Unauthorized" } ``` ``` -------------------------------- ### Executing ZFDeploy Source: https://api-tools.getlaminas.org/documentation/modules/zf-deploy Demonstrates the different ways to execute the ZFDeploy script based on installation method (standalone, composer, phar). ```shell php bin/zfdeploy.php ``` ```shell php vendor/bin/zfdeploy.php ``` ```shell php zfdeploy.phar ``` -------------------------------- ### GET /api/config/module?module={module name} Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-admin Examine and manipulate the configuration file for a specific module. ```APIDOC ## GET /api/config/module?module={module name} ### Description This endpoint operates similarly to `/api/config`, but targets the configuration file of a specified module. ### Method GET ### Endpoint /api/config/module ### Parameters #### Query Parameters - **module** (string) - Required - The name of the module whose configuration will be accessed. ### Response #### Success Response (200) - **Body**: Module-specific configuration data. ``` -------------------------------- ### GET /foo - Authenticated Request Source: https://api-tools.getlaminas.org/documentation/auth/authentication-http-digest Example of a successful authenticated request using HTTP Digest. ```APIDOC ## GET /foo ### Description This demonstrates a client making a request to the `/foo` endpoint with a valid HTTP Digest `Authorization` header. ### Method GET ### Endpoint /foo ### Parameters #### Query Parameters None #### Request Body None #### Headers - **Accept**: `application/json` - **Authorization**: `Digest username="ralph", realm="Secure API", nonce="2f3fdb4e7670ae34f0b5c092d720961c", uri="/foo", response="eaaf8d5ac41022635277a4196b747ba1", opaque="e66a41ca5bf6992a5479102cc787bc9", algorithm="MD5", qop=auth, nc=00000001, cnonce="c07b87e1b0cc5115"` ### Request Example ```http GET /foo HTTP/1.1 Accept: application/json Authorization: Digest username="ralph", realm="Secure API", nonce="2f3fdb4e7670ae34f0b5c092d720961c", uri="/foo", response="eaaf8d5ac41022635277a4196b747ba1", opaque="e66a41ca5bf6992a5479102cc787bc9", algorithm="MD5", qop=auth, nc=00000001, cnonce="c07b87e1b0cc5115" ``` ### Response #### Success Response (200) - **foo** (string) - Example data field. #### Response Example ```http HTTP/1.1 200 OK Content-Type: application/json { "foo": "bar" } ``` ``` -------------------------------- ### Initializing Laminas DB SQL Component Source: https://api-tools.getlaminas.org/documentation/recipes/join-tables Demonstrates the initial setup for using the laminas-db SQL abstraction layer. It shows how to create a Sql instance, which is the entry point for building SQL queries programmatically. ```php use Laminas\Db\Sql\Sql; // Where $adapter is a Laminas\Db\Adapter\AdapterInterface instance $sql = new Sql($adapter); $select = $sql->select(); ``` -------------------------------- ### URL Versioning Examples Source: https://api-tools.getlaminas.org/documentation/api-primer/versioning Demonstrates how APIs commonly use URL path prefixes or query string parameters to indicate version numbers. ```text http://api.twitter.com/1.1/ http://ws.audioscrobbler.com/2.0/ http://openapi.etsy.com/v2 ?v=1.5 ?VERSION=2011-10-01 ``` -------------------------------- ### GET /api/module/:name/authorization?version=:version Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-admin Retrieve the authorization configuration for a specific API module and version. ```APIDOC ## GET /api/module/:name/authorization?version=:version ### Description This REST endpoint retrieves the authorization configuration for a specific API module and version. It provides default values if no configuration exists. ### Method GET ### Endpoint /api/module/:name/authorization ### Parameters #### Path Parameters - **name** (string) - Required - The name of the API module. #### Query Parameters - **version** (string) - Required - The version of the API module. #### Headers - **Accept**: `application/json` ### Response #### Success Response (200) - **Body**: An authorization resource containing the configuration rules. ``` -------------------------------- ### GET /api/authentication[/:authentication_adapter] (API V2) Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-admin Fetch authentication adapters for Laminas API Tools (Version 2). ```APIDOC ## GET /api/authentication[/:authentication_adapter] (API V2) ### Description This REST endpoint fetches authentication adapters for Laminas API Tools. This endpoint is only available for API version 2. ### Method GET ### Endpoint /api/authentication[/:authentication_adapter] ### Parameters #### Headers - **Accept**: `application/vnd.api-tools.v2+json` ### Response #### Success Response (200) - **Body**: An authentication resource version 2 on success. #### Error Response (404) - Returned if no authentication adapter has been previously set up. ``` -------------------------------- ### Get Registered Validators Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-admin Retrieves a sorted list of all registered validator plugins. The response is a JSON object containing a 'validators' array. ```json { "validators": [ "list", "of", "validators" ] } ``` -------------------------------- ### GET /api/config Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-admin Retrieve the application configuration. Supports JSON responses with either flat key/value pairs or a nested tree structure. ```APIDOC ## GET /api/config ### Description This endpoint is for examining the application configuration, and providing overrides of individual values in it. All overrides are written to a single file, `config/autoload/development.php`; you can override that location in your configuration via the `api-tools-configuration.config-file` key. ### Method GET ### Endpoint /api/config ### Parameters #### Headers - **Accept**: `application/json`, `application/vnd.laminas-api-tools.v1.config+json` - `application/json`: Delivers representations as a flat array of key/value pairs, with keys being dot-separated values. - `application/vnd.laminas-api-tools.v1.config+json`: Delivers the configuration as a tree. ### Response #### Success Response (200) - **Body**: Configuration data in JSON format, either flat or nested depending on the `Accept` header. #### Response Example (application/json) ```json { "config.key": "value" } ``` #### Response Example (application/vnd.laminas-api-tools.v1.config+json) ```json { "config": { "key": "value" } } ``` ### Errors - `application/problem+json` ``` -------------------------------- ### RPC Service Method Configuration Example Source: https://api-tools.getlaminas.org/documentation/api-primer/http-negotiation Illustrates how to configure a Laminas API Tools RPC service to respond only to the GET method. ```APIDOC ## RPC Service Configuration (GET only) ### Description Configuration for an RPC service that only allows GET requests. ### Method GET ### Endpoint /api/rpc-service ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` GET /api/rpc-service HTTP/1.1 Host: example.org ``` ### Response #### Success Response (200) - **response** (object) - The response payload from the RPC service. #### Response Example ```json { "response": { "message": "Hello from RPC!" } } ``` ``` -------------------------------- ### GET /api/module/:name/authentication?version=:version (API V2) Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-admin Fetch the authentication mapping for a specific API module and version (Version 2). ```APIDOC ## GET /api/module/:name/authentication?version=:version (API V2) ### Description This REST endpoint fetches the authentication mapping for a specific API module and version. This endpoint is only available for API version 2. ### Method GET ### Endpoint /api/module/:name/authentication ### Parameters #### Path Parameters - **name** (string) - Required - The name of the API module. #### Query Parameters - **version** (string) - Required - The version of the API module. #### Headers - **Accept**: `application/vnd.api-tools.v2+json` ### Response #### Success Response (200) - **Body**: An object containing the authentication adapter name, e.g., `{ "authentication" : "adapter_name" }`. - If no authentication adapter exists, the value will be `false`. ``` -------------------------------- ### Deploy New Application with ZS-Client Source: https://api-tools.getlaminas.org/documentation/deployment/intro Deploys a new ZPK package to a specified target. Requires package filename, base URL, and target. Optionally allows vhost creation and user-defined application names. ```bash $ zs-client.phar applicationDeploy --appPackage= --baseUrl= --target [--createVhost | --defaultServer] [--userAppName ] ``` -------------------------------- ### Media Type Versioning Examples Source: https://api-tools.getlaminas.org/documentation/api-primer/versioning Illustrates two methods for versioning within the Accept header: as part of the media type name or as a parameter. ```text application/vnd.status.v2+json application/vnd.status+json; version=2 ``` -------------------------------- ### REST Resource Management Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-admin This is the canonical endpoint for REST resources. It can be used for any type of REST resource, including DB-Connected ones. The endpoint supports collection methods (GET, POST, DELETE) and resource methods (GET, PATCH). It also allows filtering results by version using a query string parameter. ```APIDOC ## GET /websites/api-tools_getlaminas/api/module/:name/rest[/:controller_service_name] ### Description Retrieves REST resources. Returns a single resource if `controller_service_name` is provided, otherwise returns a collection of resources. ### Method GET ### Endpoint /websites/api-tools_getlaminas/api/module/:name/rest[/:controller_service_name] #### Query Parameters - **version** (string) - Optional - Filters results by version. ### Response #### Success Response (200) - Returns a single REST resource or a collection of REST resources. - **Content-Type**: `application/json` ### Response Example { "example": "[REST resource or collection of REST resources]" } ## POST /websites/api-tools_getlaminas/api/module/:name/rest ### Description Creates a new REST service. ### Method POST ### Endpoint /websites/api-tools_getlaminas/api/module/:name/rest #### Request Body - **resource_name** (string) - Required - Describes the REST service to create. - Additional properties for DB-Connected resources (optional): `adapter_name`, `table_name`, `hydrator_name`, `table_service`. ### Request Example { "resource_name": "Status" } ### Response #### Success Response (200) - Returns the created REST resource. - **Content-Type**: `application/json` ### Response Example { "example": "[Created REST resource]" } ## DELETE /websites/api-tools_getlaminas/api/module/:name/rest[/:controller_service_name] ### Description Deletes a REST resource. ### Method DELETE ### Endpoint /websites/api-tools_getlaminas/api/module/:name/rest[/:controller_service_name] ### Response #### Success Response (200) - Indicates successful deletion. - **Content-Type**: `application/json` ### Response Example { "example": "[Success message]" } ## GET /websites/api-tools_getlaminas/api/module/:name/rest/:controller_service_name ### Description Retrieves a specific REST resource. ### Method GET ### Endpoint /websites/api-tools_getlaminas/api/module/:name/rest/:controller_service_name ### Response #### Success Response (200) - Returns the requested REST resource. - **Content-Type**: `application/json` ### Response Example { "example": "[Specific REST resource]" } ## PATCH /websites/api-tools_getlaminas/api/module/:name/rest/:controller_service_name ### Description Updates a specific REST resource. ### Method PATCH ### Endpoint /websites/api-tools_getlaminas/api/module/:name/rest/:controller_service_name #### Request Body - **[fields to update]** (any) - Required/Optional - Fields to update for the resource. ### Request Example { "example": "[Fields to update]" } ### Response #### Success Response (200) - Returns the updated REST resource. - **Content-Type**: `application/json` ### Response Example { "example": "[Updated REST resource]" } ``` -------------------------------- ### GET /api-tools-version Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-admin Retrieves the current Laminas API Tools version. Returns the version in a 'version' key or '@dev' if it cannot be discovered. Available since 1.5.1. ```APIDOC ## GET /api-tools-version ### Description Returns the current Laminas API Tools version if it can be discovered, and the string `@dev` otherwise. The payload is in the `version` key. ### Method `GET` ### Endpoint `/api-tools-version` ### Parameters #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **version** (string) - The current API Tools version or `@dev`. #### Response Example ```json { "version": "1.4.0" } ``` ``` -------------------------------- ### ZFDeploy Build Command Syntax Source: https://api-tools.getlaminas.org/documentation/modules/zf-deploy Provides the full syntax and arguments for the 'build' command, detailing various options. ```shell Usage: build [--target=] [--modules=] [--vendor|-v]:vendor [--composer=] [--gitignore=] [--deploymentxml=] [--zpkdata=] [--version=] Arguments: Name of the package file to create; suffix must be .zip, .tar, .tar.gz, .tgz, or .zpk --target The target directory of the application to package; defaults to current working directory --modules Comma-separated list of modules to include in build --vendor|-v Whether or not to include the vendor directory (disabled by default) --composer Whether or not to execute composer; "on" or "off" ("on" by default) --gitignore Whether or not to parse the .gitignore file to determine what files/folders to exclude; "on" or "off" ("on" by default) --configs Path to directory containing application config files to include in the package --deploymentxmlPath to a custom deployment.xml to use when building a ZPK package --zpkdata Path to a directory containing ZPK package assets (deployment.xml, logo, scripts, etc.) --version Specific application version to use for a ZPK package ``` -------------------------------- ### Access API Resource with Bearer Token (HTTP) Source: https://api-tools.getlaminas.org/documentation/auth/authentication-oauth2 An example HTTP GET request to access a protected resource, demonstrating the inclusion of the Bearer token in the Authorization header. ```http GET /oauth/resource HTTP/1.1 Accept: application/json Authorization: Bearer 907c762e069589c2cd2a229cdae7b8778caa9f07 ``` -------------------------------- ### ApiProblem Constructor Example (PHP) Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-api-problem Demonstrates how to instantiate the ApiProblem class with status, detail, type, title, and additional properties. ```php class ApiProblem { public function __construct( $status, $detail, $type = null, $title = null, array $additional = [] ) { /* ... */ } } ``` ```php new ApiProblem(404, 'Entity not found'); // or new ApiProblem(424, $exceptionInstance); ``` -------------------------------- ### OAuth2 Testing Setup Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-oauth2 Instructions on how to set up the OAuth2 database with client credentials and generate password hash values. ```APIDOC ## How to test OAuth2 To test the OAuth2 module, you need to add a `client_id` and `client_secret` to the `oauth2` database. For the SQLite test database, the default `testclient`/`testpass` account can be used without adding a `client_id`. ### Password Hashing Passwords must be encrypted using the `Laminas\Crypt\Password\Bcrypt` class. A script `/bin/bcrypt.php` is provided for generating password hash values from the command line: ```bash php bin/bcrypt.php ``` For example: ```bash php bin/bcrypt.php testpass ``` This will output a hash string, e.g.: ``` $2y$14$f3qml4G2hG6sxM26VMq.geDYbsS089IBtVJ7DlD05BoViS9PFykE2 ``` ### Database Client Insertion After generating the `client_secret` hash, insert a new client into the `oauth_clients` table: ```sql INSERT INTO oauth_clients ( client_id, client_secret, redirect_uri ) VALUES ( "testclient", "$2y$14$f3qml4G2hG6sxM26VMq.geDYbsS089IBtVJ7DlD05BoViS9PFykE2", "/oauth/receivecode" ); ``` ``` -------------------------------- ### API Tools Version Endpoint Response Source: https://api-tools.getlaminas.org/documentation/modules/api-tools-admin Example JSON response from the /api-tools-version endpoint, indicating the current Laminas API Tools version. Returns '@dev' if the version cannot be discovered. ```json { "version": "1.4.0" } ``` -------------------------------- ### Get Specific Validated File Upload Value Source: https://api-tools.getlaminas.org/documentation/recipes/upload-files-to-api Illustrates how to retrieve the validated data for a specific file upload field, named 'image' in this example, using the `getValue()` method. ```php $image = $inputFilter->getValue('image'); ``` -------------------------------- ### ZFDeploy Available Commands Source: https://api-tools.getlaminas.org/documentation/modules/zf-deploy Lists the main commands available in the ZFDeploy tool. ```shell $ zfdeploy ZFDeploy, version 0.3.0-dev Available commands: build Build a deployment package help Get help for individual commands self-update Updates zfdeploy.phar to the latest version version Display the version of the script ``` -------------------------------- ### Example of a failed HTTP Digest Authentication request Source: https://api-tools.getlaminas.org/documentation/auth/authentication-http-digest This snippet illustrates an HTTP GET request with an invalid 'Authorization' header for Digest authentication. This would typically result in a 401 Unauthorized response from the server. ```http GET /foo HTTP/1.1 Accept: application/json Authorization: Digest clearly-invalid-token ``` -------------------------------- ### OPTIONS Response Example (200 OK) Source: https://api-tools.getlaminas.org/documentation/api-primer/http-negotiation Shows a successful OPTIONS response, indicating the allowed HTTP methods for a given URI. ```http HTTP/1.1 200 OK Allow: GET, POST ```