### Enable Offer Generation Per Starting Point (JSON) Source: https://github.com/pressmind/sdk/blob/master/documentation/config-touristic-data.md Example JSON configuration to enable generating a separate offer for each departure point. ```json "generate_offer_for_each_startingpoint_option": true ``` -------------------------------- ### Complete Configuration Example Source: https://github.com/pressmind/sdk/blob/master/documentation/config-server-database.md A full example of the configuration structure, including development server and database settings. ```json { "development": { "server": { "document_root": "/var/www/travelsite/httpdocs", "webserver_http": "https://www.my-travel-site.com", "php_cli_binary": "/usr/bin/php8.2", "timezone": "Europe/Berlin" }, "database": { "username": "pressmind_user", "password": "s3cur3_p4ssw0rd!", "host": "127.0.0.1", "port": "3306", "dbname": "pressmind_production", "engine": "MySQL" } } } ``` -------------------------------- ### Filesystem Bucket Example Source: https://github.com/pressmind/sdk/blob/master/documentation/config-image-file-handling.md Example of a 'bucket' configuration for filesystem storage, specifying a directory path. ```json "bucket": "WEBSERVER_DOCUMENT_ROOT/assets/images" ``` -------------------------------- ### Full PHP Example for Session Key Authentication Source: https://github.com/pressmind/sdk/blob/master/documentation/backend.md This example demonstrates full authentication using a custom session key 'myapp_user'. It includes functions for checking authentication status, getting user information, and generating login/logout URLs. Ensure the session is started before use. ```php // Ensure session is started for nonces and auth if (session_status() === PHP_SESSION_NONE) { session_start(); } $auth = new Pressmind Backend Auth CallbackProvider([ 'isAuthenticated' => function () { return !empty($_SESSION['myapp_user']); }, 'getCurrentUser' => function () { return $_SESSION['myapp_user']['name'] ?? null; }, 'getLoginUrl' => function ($returnUrl) { $base = '/myapp/login.php'; return $returnUrl !== '' ? $base . '?return=' . urlencode($returnUrl) : $base; }, 'getLogoutUrl' => function () { return '/myapp/logout.php'; }, 'renderLoginForm' => function () { return null; // we use external login page }, 'handleLoginRequest' => function () { return false; // login is handled by /myapp/login.php }, 'createNonce' => function (string $action) { $key = 'nonce_' . $action; if (!isset($_SESSION[$key])) { $_SESSION[$key] = bin2hex(random_bytes(16)); } return $_SESSION[$key]; }, 'verifyNonce' => function (string $nonce, string $action) { $key = 'nonce_' . $action; return isset($_SESSION[$key]) && hash_equals($_SESSION[$key], $nonce); }, ]); $app = new Pressmind Backend Application($auth); $app->handle(); ``` -------------------------------- ### Install Composer Dependencies and Run Unit Tests Source: https://github.com/pressmind/sdk/blob/master/documentation/testing.md Install project dependencies using Composer and then run the unit test suite. This is the basic setup for running tests locally without Docker. ```bash composer install --no-scripts composer test ``` -------------------------------- ### Logging Storage Examples Source: https://github.com/pressmind/sdk/blob/master/documentation/config-logging.md Provides examples for setting the `logging.storage` property to choose between database and filesystem logging. ```json // Default: Log to database "storage": "database" ``` ```json // Alternative: Log to files "storage": "filesystem" ``` -------------------------------- ### SDK CLI Import Example Source: https://github.com/pressmind/sdk/blob/master/documentation/cli-reference.md Example of how to perform a full import using the SDK CLI. ```APIDOC ## Example: Full Import This example demonstrates how to initiate a full import of all products from the PIM using the SDK CLI. ### Command ```bash php bin/import fullimport ``` ### Description This command triggers the `fullimport` subcommand, which fetches all media objects from the PIM, performs a full import for each, and executes subsequent post-import processes. ``` -------------------------------- ### Retrieve Starting Points by ID(s) (Bash) Source: https://github.com/pressmind/sdk/blob/master/documentation/pressmind-api-endpoints.md Example using curl to fetch starting point options by one or more IDs. Used for import of departure locations. ```bash curl -X GET \ "https://webcore.pressmind.io/v2-23/rest/{API_KEY}/StartingPoint/getById?ids[]=1&ids[]=2&cache=0" \ -H "Content-Type: application/json; charset=utf-8" \ -u "{API_USER}:{API_PASSWORD}" ``` -------------------------------- ### First-time Setup with Make Source: https://github.com/pressmind/sdk/blob/master/documentation/testing.md Follow these steps for initial setup, including building Docker images, running unit tests, and recording API snapshots for integration tests. ```bash # 1. Build Docker images make test-docker-build # 2. Run Unit tests (no services needed) make test-unit # 3. For ImportIntegration: set up API credentials and record a snapshot cp .env.example .env # Edit .env and fill in PM_API_KEY, PM_API_USER, PM_API_PASSWORD # 4. Record API snapshot (calls live pressmind API, saves responses as JSON fixtures) make test-record-api-snapshot # 5. Now run ImportIntegration tests (uses recorded fixtures, no live API needed) make test-import-integration # 6. Or run everything at once make test-all ``` -------------------------------- ### First-time Project Setup Source: https://github.com/pressmind/sdk/blob/master/documentation/makefile.md Commands for initial project setup, including building the Docker image, running unit tests, and optionally recording API snapshots for integration tests. ```bash make test-docker-build make test-unit # Optional: record API snapshot for ImportIntegration cp .env.example .env # edit .env with API credentials make test-record-api-snapshot make test-import-integration ``` -------------------------------- ### Configure Touristic Origins Examples Source: https://github.com/pressmind/sdk/blob/master/documentation/config-touristic-data.md Examples of how to define touristic origins in the configuration. ```json "origins": ["0"] ``` ```json "origins": ["0", "1", "2"] ``` ```json "origins": ["3"] ``` -------------------------------- ### S3 Bucket Example Source: https://github.com/pressmind/sdk/blob/master/documentation/config-image-file-handling.md Example of a 'bucket' configuration for S3 storage, specifying the S3 bucket name. ```json "bucket": "my-pressmind-images" ``` -------------------------------- ### Example Configuration for Media Types Source: https://github.com/pressmind/sdk/blob/master/documentation/config-touristic-data.md An example JSON structure for registering available media types, mapping their IDs to names. ```json "media_types": { "123": {"name": "Trip"}, "456": {"name": "Hotel"}, "789": {"name": "Attraction"} } ``` -------------------------------- ### Basic Auth Configuration Example (JSON) Source: https://github.com/pressmind/sdk/blob/master/documentation/backend.md Example JSON configuration for enabling basic authentication for the backend. Ensure username and password are provided. ```json "backend": { "enabled": true, "cli_runner": "APPLICATION_PATH/cli/run.php", "auth": { "provider": "basic_auth", "config": { "username": "admin", "password": "your-secret-password" } } } ``` -------------------------------- ### Server Configuration Example Source: https://github.com/pressmind/sdk/blob/master/documentation/config-server-database.md Defines fundamental environment settings for the server. ```json "server": { "document_root": "BASE_PATH/httpdocs", "webserver_http": "http://127.0.0.1", "php_cli_binary": "php", "timezone": "Europe/Berlin" } ``` -------------------------------- ### SSE Stream Example for Command Execution Source: https://github.com/pressmind/sdk/blob/master/documentation/rest-api-endpoints.md Illustrates the Server-Sent Events (SSE) stream format for command execution, including start, message, error, and complete events. ```text data: {"event":"start","message":"Process started"} data: {"type":"line","text":"Importing..."} event: complete data: {"event":"complete","success":true,"exitCode":0} ``` -------------------------------- ### Cache Key Format Examples Source: https://github.com/pressmind/sdk/blob/master/documentation/config-cache.md Defines the structure for cache keys and provides examples for setting the key prefix. ```json "key_prefix": "DATABASE_NAME" ``` ```json "key_prefix": "my_project" ``` ```json "key_prefix": "pressmind_staging" ``` -------------------------------- ### OpenSearch Server URI Examples Source: https://github.com/pressmind/sdk/blob/master/documentation/config-search.md Provides examples of OpenSearch server URI configurations for different deployment scenarios. ```json // Docker Compose "uri": "http://opensearch:9200" ``` ```json // Local "uri": "http://127.0.0.1:9200" ``` ```json // With HTTPS "uri": "https://opensearch.example.com:9200" ``` ```json // AWS OpenSearch Service "uri": "https://search-domain.region.es.amazonaws.com" ``` -------------------------------- ### Cache Types Configuration Examples Source: https://github.com/pressmind/sdk/blob/master/documentation/config-cache.md Provides examples of how to configure the 'types' array to enable specific caching mechanisms. ```json "types": ["REST", "SEARCH", "SEARCH_FILTER", "OBJECT", "MONGODB", "OPENSEARCH"] ``` ```json "types": ["REST"] ``` ```json "types": ["REST", "SEARCH", "SEARCH_FILTER", "MONGODB"] ``` -------------------------------- ### Redis Authentication Configuration Example Source: https://github.com/pressmind/sdk/blob/master/documentation/config-cache.md This JSON example demonstrates how to configure the password for an authenticated Redis connection within the cache adapter settings. ```json "config": { "host": "redis.example.com", "port": 6379, "password": "r3d1s_p4ss!" } ``` -------------------------------- ### Redis Host Examples Source: https://github.com/pressmind/sdk/blob/master/documentation/config-cache.md These JSON examples show different ways to configure the 'host' property for the Redis cache adapter, including local, Docker Compose, and external server configurations. ```json // Local Redis "host": "127.0.0.1" ``` ```json // Docker Compose "host": "redis" ``` ```json // External server "host": "redis.example.com" ``` -------------------------------- ### Pagination Examples Source: https://github.com/pressmind/sdk/blob/master/documentation/search-mongodb-api.md Demonstrates how to control pagination by specifying the page number and the number of results per page. ```text pm-l=1,12 // Page 1, 12 results per page pm-l=2,12 // Page 2, 12 results per page pm-l=1,24 // Page 1, 24 results per page pm-l=3,10 // Page 3, 10 results per page ``` -------------------------------- ### Complete OpenSearch Index Mapping Example Source: https://github.com/pressmind/sdk/blob/master/documentation/config-search.md An example demonstrating a complete OpenSearch index mapping configuration with 'code', 'headline_default', and 'subline_default' fields. ```json "index": { "code": { "type": "keyword", "object_type_mapping": { "607": [{"language": null, "field": {"name": "code", "params": []}}], "609": [{"language": null, "field": {"name": "code", "params": []}}] } }, "headline_default": { "type": "text", "object_type_mapping": { "607": [{"language": null, "field": {"name": "headline_default", "params": []}}], "609": [{"language": null, "field": {"name": "headline_default", "params": []}}] } }, "subline_default": { "type": "text", "boost": 2, "object_type_mapping": { "607": [{"language": null, "field": {"name": "subline_default", "params": []}}], "609": [{"language": null, "field": {"name": "subline_default", "params": []}}] } } } ``` -------------------------------- ### Example Calculation for CheapestPriceSpeed Entries Source: https://github.com/pressmind/sdk/blob/master/documentation/cheapest-price-aggregation.md Provides a concrete example of how the number of CheapestPriceSpeed entries is derived based on typical product data. ```plaintext 2 × 50 × 5 × 3 × 1 × 2 = 3,000 CheapestPriceSpeed entries ``` -------------------------------- ### Backend Configuration Example Source: https://context7.com/pressmind/sdk/llms.txt Example JSON configuration for the Pressmind SDK backend, specifying enablement, CLI runner path, and authentication provider details. ```json { "backend": { "enabled": true, "cli_runner": "APPLICATION_PATH/cli/run.php", "auth": { "provider": "password", "config": { "password": "change-me-in-production" } } } } ``` -------------------------------- ### REST Client API Key Example Source: https://github.com/pressmind/sdk/blob/master/documentation/config-rest-api.md Provides an example of a valid API key format for the REST client. ```json "api_key": "abc123def456ghi789" ``` -------------------------------- ### Example Configuration for Primary Media Type IDs Source: https://github.com/pressmind/sdk/blob/master/documentation/config-touristic-data.md Examples of how to configure `primary_media_type_ids` to restrict imports to specific object types or allow all types. ```json "primary_media_type_ids": [123, 456] // Allow all types (default) "primary_media_type_ids": null ``` -------------------------------- ### Example Configuration for Media Types Allowed Visibilities Source: https://github.com/pressmind/sdk/blob/master/documentation/config-touristic-data.md An example JSON structure defining which visibility levels are allowed for specific object types. ```json "media_types_allowed_visibilities": { "123": [30, 60], "456": [30, 60, 90] } ``` -------------------------------- ### Filesystem Logging Configuration Source: https://github.com/pressmind/sdk/blob/master/documentation/config-logging.md Example configuration for logging to the filesystem, specifying log path and retention. ```json "logging": { "mode": ["ERROR", "WARNING"], "storage": "filesystem", "log_file_path": "/var/log/pressmind", "lifetime": 2592000, "enable_advanced_object_log": false, "enable_database_query_logging": false } ``` -------------------------------- ### Example MyContent Class Mapping Source: https://github.com/pressmind/sdk/blob/master/documentation/config-touristic-data.md Demonstrates mapping MyContent IDs to custom importer classes. ```json "my_content_class_map": { "42": "\Custom\Import\HotelAmenities", "99": "\Custom\Import\TransferService" } ``` -------------------------------- ### Minimal PHP Example for API Key Authentication Source: https://github.com/pressmind/sdk/blob/master/documentation/backend.md This minimal example shows authentication using an API key from the 'X-API-KEY' header. It's suitable for scenarios where a full login form or session management is not required. For production, consider adding nonce verification and user identification. ```php $auth = new Pressmind Backend Auth CallbackProvider([ 'isAuthenticated' => function () { return isset($_SERVER['HTTP_X_API_KEY']) && $_SERVER['HTTP_X_API_KEY'] === getenv('BACKEND_API_KEY'); }, ]); $app = new Pressmind Backend Application($auth); $app->handle(); ``` -------------------------------- ### Logging Mode Examples Source: https://github.com/pressmind/sdk/blob/master/documentation/config-logging.md Illustrates different configurations for the `logging.mode` property to control which log types are stored. ```json // Only log errors (default, minimal) "mode": ["ERROR"] ``` ```json // Log errors and warnings "mode": ["ERROR", "WARNING"] ``` ```json // Log everything (debugging) "mode": ["ALL"] ``` ```json // Detailed logging for development "mode": ["DEBUG", "INFO", "WARNING", "ERROR", "FATAL"] ``` -------------------------------- ### Filter by URL Match Source: https://github.com/pressmind/sdk/blob/master/documentation/search-mongodb-api.md Example for finding a product by its specific URL path. ```text pm-url=/travel/5-beautiful-mallorca/ ``` -------------------------------- ### Minimal Logging Configuration (Production) Source: https://github.com/pressmind/sdk/blob/master/documentation/config-logging.md Example configuration for minimal logging, suitable for production environments. ```json "logging": { "mode": ["ERROR"], "categories": ["ALL"], "storage": "database", "lifetime": 604800, "keep_log_types": ["ERROR", "FATAL"], "enable_advanced_object_log": false, "enable_database_query_logging": false } ``` -------------------------------- ### PHP Example View Template Source: https://github.com/pressmind/sdk/blob/master/src/Pressmind/ObjectTypeScaffolderTemplates/Example.txt This PHP template is used for rendering the example view of a Media Object Type. It demonstrates how to access and display data such as the cheapest price and media object properties. ```php getCheapestPrice(); ?>
Open the file ###VIEWFILEPATH### in a text editor, to see how the information in this file was rendered
toStdClass());?>
toStdClass());?>