### Install React Stream via Composer Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/stream/README.md Command to install the library using the Composer dependency manager. ```bash composer require react/stream:^1.4 ``` -------------------------------- ### PHP WebSocket Chat Server Example Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/cboden/ratchet/README.md This PHP code demonstrates how to set up a basic WebSocket chat server using the Ratchet library. It requires composer dependencies to be installed and runs on a specified port. The server handles new connections, broadcasts messages to all clients except the sender, and manages disconnections and errors. ```php clients = new \SplObjectStorage; } public function onOpen(ConnectionInterface $conn) { $this->clients->attach($conn); } public function onMessage(ConnectionInterface $from, $msg) { foreach ($this->clients as $client) { if ($from != $client) { $client->send($msg); } } } public function onClose(ConnectionInterface $conn) { $this->clients->detach($conn); } public function onError(ConnectionInterface $conn, \Exception $e) { $conn->close(); } } // Run the server application through the WebSocket protocol on port 8080 $app = new Ratchet\App('localhost', 8080); $app->route('/chat', new MyChat, array('*')); $app->route('/echo', new Ratchet\Server\EchoServer, array('*')); $app->run(); ``` -------------------------------- ### Install Événement using Composer Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/evenement/evenement/README.md The recommended method for installing the Événement library is through Composer. This command adds the library as a dependency to your PHP project. ```bash composer require evenement/evenement ``` -------------------------------- ### Install Dependencies for Testing (Bash) Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/cache/README.md Shows the Composer command to install all necessary dependencies for running the project's test suite after cloning the repository. ```bash composer install ``` -------------------------------- ### Install React Promise via Composer Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/promise/README.md Commands to install the library using Composer, including version-specific requirements for different PHP environments. ```bash composer require react/promise:^3.2 ``` ```bash composer require "react/promise:^3 || ^2 || ^1" ``` -------------------------------- ### Install Library using Composer Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/jumbojett/openid-connect-php/README.md Instructions for installing the OpenID Connect client library using Composer, a dependency manager for PHP. This is the primary method for including the library in your project. ```bash composer require jumbojett/openid-connect-php ``` -------------------------------- ### JavaScript WebSocket Client Example Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/cboden/ratchet/README.md This JavaScript code provides a client-side example for connecting to a WebSocket server, specifically the echo server set up by Ratchet. It establishes a connection, logs received messages to the console, and sends an initial message upon successful connection. This snippet is intended to be run in a web browser. ```javascript // Then some JavaScript in the browser: var conn = new WebSocket('ws://localhost:8080/echo'); conn.onmessage = function(e) { console.log(e.data); }; conn.onopen = function(e) { conn.send('Hello Me!'); }; ``` -------------------------------- ### Repomanager API Authentication Examples Source: https://context7.com/lbr38/repomanager/llms.txt Examples demonstrating how to authenticate with the Repomanager REST API using either an API key for administrative operations or a Host ID and Token for registered hosts. It also shows how to check the API status. ```bash # API Key authentication (for admin operations) curl -H "Authorization: Bearer " https://repomanager.example.com/api/v2/repo/ # Host ID+Token authentication (for registered hosts) curl -H "Authorization: Host :" https://repomanager.example.com/api/v2/host/status # Check API status curl -s https://repomanager.example.com/api/v2/status | jq # Output: {"return":"201","status":"OK"} ``` -------------------------------- ### Install ReactPHP Event Loop via Composer Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/event-loop/README.md Command to install the latest version of the react/event-loop library using the Composer dependency manager. ```bash composer require react/event-loop:^1.6 ``` -------------------------------- ### Check Running Docker Containers Source: https://github.com/lbr38/repomanager/wiki/01.-Installation-and-update This command lists all currently running Docker containers. It's used to verify that the Repomanager container has started successfully and is in an 'Up' status. The output shows container ID, image, command, creation time, status, ports, and name. ```bash docker ps ``` -------------------------------- ### Run project tests Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/event-loop/README.md Commands to install project dependencies and execute the PHPUnit test suite for the library. ```bash composer install vendor/bin/phpunit ``` -------------------------------- ### Run Tests and Static Analysis Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/promise/README.md Commands to install project dependencies and execute the test suite using PHPUnit and static analysis via PHPStan. ```bash composer install ``` ```bash vendor/bin/phpunit ``` ```bash vendor/bin/phpstan ``` -------------------------------- ### Nginx Reverse Proxy Configuration Source: https://github.com/lbr38/repomanager/wiki/01.-Installation-and-update This is an example Nginx configuration for setting up a reverse proxy to access the Repomanager web interface. It defines an upstream server pointing to the Repomanager Docker container and includes placeholders for server IP, FQDN, and SSL certificate paths. This setup is crucial for secure access via HTTPS. ```nginx upstream repomanager_docker { server 127.0.0.1:8080; } ``` -------------------------------- ### Install ArrayCache via Composer (Bash) Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/cache/README.md Provides the Composer command to install the ArrayCache library. It specifies version constraints for compatibility. ```bash composer require react/cache:^1.2 ``` -------------------------------- ### PUT /api/v2/host/packages/installed Source: https://context7.com/lbr38/repomanager/llms.txt Reports the list of currently installed packages on the host for inventory tracking. ```APIDOC ## PUT /api/v2/host/packages/installed ### Description Updates the inventory of installed packages on the host. ### Method PUT ### Endpoint https://repomanager.example.com/api/v2/host/packages/installed ### Request Body - **installed_packages** (string) - Required - Pipe-delimited list of packages and versions (e.g., name|version,name|version) ### Request Example { "installed_packages": "nginx|1.24.0-1ubuntu1,curl|7.81.0-1ubuntu1.15" } ### Response #### Success Response (201) - **return** (integer) - Status code - **message** (array) - Success confirmation ``` -------------------------------- ### Send Installed Packages List (Bash) Source: https://context7.com/lbr38/repomanager/llms.txt Reports the list of installed packages on a host to Repomanager for inventory tracking. This uses a PUT request with a JSON payload containing a string of package names and versions. Authentication is required. ```bash curl -L --post301 -s -q -X PUT \ -H "Authorization: Host :" \ -H "Content-Type: application/json" \ -d '{ "installed_packages": "nginx|1.24.0-1ubuntu1,curl|7.81.0-1ubuntu1.15,openssl|3.0.2-0ubuntu1.12,php8.1|8.1.27-1+ubuntu22.04.1" }' \ https://repomanager.example.com/api/v2/host/packages/installed ``` -------------------------------- ### Write and End Stream Operations in PHP Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/stream/README.md Demonstrates how to write data chunks to a stream and properly terminate the connection. The examples show standard usage, shorthand final data transmission, and the non-writable state transition after closing. ```php $stream->write('hello'); $stream->write('world'); $stream->end(); ``` ```php // shorter version $stream->end('bye'); // same as longer version $stream->write('bye'); $stream->end(); ``` ```php $stream->end(); assert($stream->isWritable() === false); $stream->write('nope'); // NO-OP $stream->end(); // NO-OP ``` -------------------------------- ### Install Constant-Time Encoding via Composer Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/paragonie/constant_time_encoding/README.md This command installs the library using Composer, the dependency manager for PHP. It ensures that the library and its dependencies are correctly downloaded and made available to your project. ```sh composer require paragonie/constant_time_encoding ``` -------------------------------- ### Install Symfony Routing Component Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/symfony/routing/README.md This command installs the Symfony Routing component using Composer. It is a prerequisite for using the routing features in your Symfony project. ```bash composer require symfony\/routing ``` -------------------------------- ### Basic OpenID Connect Client Authentication Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/jumbojett/openid-connect-php/README.md Example of initializing and using the OpenID Connect client for basic user authentication. It involves setting the provider's URL, client ID, client secret, and optionally a certificate path, then initiating the authentication process and requesting user info. ```php use Jumbojett\OpenIDConnectClient; $oidc = new OpenIDConnectClient('https://id.provider.com', 'ClientIDHere', 'ClientSecretHere'); $oidc->setCertPath('/path/to/my.cert'); $oidc->authenticate(); $name = $oidc->requestUserInfo('given_name'); ``` -------------------------------- ### GET /api/v2/repo/ Source: https://context7.com/lbr38/repomanager/llms.txt Retrieve a comprehensive list of all configured repositories, including metadata such as name, type, distribution, and environment settings. ```APIDOC ## GET /api/v2/repo/ ### Description Retrieve a list of all configured repositories with their metadata including name, type, distribution, and environment settings. ### Method GET ### Endpoint /api/v2/repo/ ### Parameters #### Query Parameters - **Authorization** (header) - Required - Bearer ### Request Example curl -H "Authorization: Bearer " https://repomanager.example.com/api/v2/repo/ ### Response #### Success Response (200) - **repositories** (array) - List of repository objects containing metadata. #### Response Example { "repositories": [ { "id": "repo-01", "name": "ubuntu-focal-main", "type": "deb", "environment": "prod" } ] } ``` -------------------------------- ### Docker Deployment for Repomanager Source: https://context7.com/lbr38/repomanager/llms.txt Instructions for deploying Repomanager using Docker containers. It includes examples for both bridge and host network modes, specifying persistent volumes for data and repository storage. The default credentials are also provided. ```bash # Bridge network mode (default) docker run -d --restart unless-stopped --name repomanager \ -e FQDN=repomanager.example.com \ -e MAX_UPLOAD_SIZE=32M \ -p 8080:8080 \ -v /etc/localtime:/etc/localtime:ro \ -v /var/lib/docker/volumes/repomanager-data:/var/lib/repomanager \ -v /var/lib/docker/volumes/repomanager-repo:/home/repo \ lbr38/repomanager:latest # Host network mode (recommended for public servers) docker run -d --restart unless-stopped --name repomanager --network=host \ -e FQDN=repomanager.example.com \ -e MAX_UPLOAD_SIZE=32M \ -e NGINX_LISTEN_PORT=8080 \ -v /etc/localtime:/etc/localtime:ro \ -v /var/lib/docker/volumes/repomanager-data:/var/lib/repomanager \ -v /var/lib/docker/volumes/repomanager-repo:/home/repo \ lbr38/repomanager:latest # Verify container is running docker ps # Output: # CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES # 61088656e1bd lbr38/repomanager:latest "/tmp/entrypoint.sh" 12 seconds ago Up 10 seconds 0.0.0.0:8080->8080/tcp repomanager # Default credentials: admin / repomanager ``` -------------------------------- ### Include Composer Autoloader Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/jumbojett/openid-connect-php/README.md Demonstrates how to include the Composer autoloader file in your PHP script. This is necessary to make the installed library classes available for use. ```php require __DIR__ . '/vendor/autoload.php'; ``` -------------------------------- ### Create Secure Connector and Connect - PHP Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/socket/README.md Shows how to create a SecureConnector by wrapping a DnsConnector and then establish a secure TLS connection to a given host and port. The example includes writing data to the secure connection. ```php $secureConnector = new React\Socket\SecureConnector($dnsConnector); $secureConnector->connect('www.google.com:443')->then(function (React\Socket\ConnectionInterface $connection) { $connection->write("GET / HTTP/1.0\r\nHost: www.google.com\r\n\r\n"); ... }); ``` -------------------------------- ### Handle Secure Server Connections Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/socket/README.md An example of how to listen for the 'connection' event on a SecureServer. This event is emitted when a client successfully completes the TLS handshake, providing a ConnectionInterface instance. ```php $server->on('connection', function (React\Socket\ConnectionInterface $connection) { echo 'Secure connection from' . $connection->getRemoteAddress() . PHP_EOL; $connection->write('hello there!' . PHP_EOL); … }); ``` -------------------------------- ### PKCE Client for Authorization Code Flow Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/jumbojett/openid-connect-php/README.md Example of implementing a Proof Key for Code Exchange (PKCE) flow. This enhances security for public clients (like mobile or single-page applications) by adding a dynamic secret to the authorization code exchange. ```php use Jumbojett\OpenIDConnectClient; $oidc = new OpenIDConnectClient('https://id.provider.com', 'ClientIDHere', null); $oidc->setCodeChallengeMethod('S256'); $oidc->authenticate(); $name = $oidc->requestUserInfo('given_name'); ``` -------------------------------- ### Perform DNS Queries with TcpTransportExecutor Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/dns/README.md Demonstrates how to use TcpTransportExecutor to send DNS queries over TCP. Includes examples of wrapping the executor with TimeoutExecutor and CoopExecutor for improved reliability and efficiency. ```php $executor = new TcpTransportExecutor('8.8.8.8:53'); $executor->query( new Query($name, Message::TYPE_AAAA, Message::CLASS_IN) )->then(function (Message $message) { foreach ($message->answers as $answer) { echo 'IPv6: ' . $answer->data . PHP_EOL; } }, 'printf'); $executor = new TimeoutExecutor( new TcpTransportExecutor($nameserver), 3.0 ); $executor = new CoopExecutor( new TimeoutExecutor( new TcpTransportExecutor($nameserver), 3.0 ) ); ``` -------------------------------- ### Create Connection Limiting Server with Pause (PHP) Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/socket/README.md Configures a LimitingServer to pause accepting new connections once the limit is reached. This example sets a limit of 100 connections and enables the pause behavior. The underlying server is paused, and connections are rejected until the active count drops below the limit. ```php $server = new React\Socket\LimitingServer($server, 100, true); $server->on('connection', function (React\Socket\ConnectionInterface $connection) { $connection->write('hello there!' . PHP_EOL); … }); ``` -------------------------------- ### Get Active Connections (PHP) Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/socket/README.md Retrieves an array of all currently active connections from a LimitingServer. The example iterates through the connections and sends a 'Hi!' message to each. ```php foreach ($server->getConnection() as $connection) { $connection->write('Hi!'); } ``` -------------------------------- ### Basic Client for Implicit Flow (e.g., Azure AD B2C) Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/jumbojett/openid-connect-php/README.md Example of configuring the client for the implicit OpenID Connect flow, often used with services like Azure AD B2C. This involves setting specific response types, enabling implicit flow, and configuring the response mode. ```php use Jumbojett\OpenIDConnectClient; $oidc = new OpenIDConnectClient('https://id.provider.com', 'ClientIDHere', 'ClientSecretHere'); $oidc->setResponseTypes(['id_token']); $oidc->setAllowImplicitFlow(true); $oidc->addAuthParam(['response_mode' => 'form_post']); $oidc->setCertPath('/path/to/my.cert'); $oidc->authenticate(); $sub = $oidc->getVerifiedClaims('sub'); ``` -------------------------------- ### Configure Buffer Soft Limit Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/stream/README.md Demonstrates how to initialize the stream with a custom write buffer soft limit in bytes. ```php $stream = new WritableResourceStream(STDOUT, null, 8192); ``` -------------------------------- ### Manage Repomanager Docker Container Source: https://github.com/lbr38/repomanager/wiki/01.-Installation-and-update Commands to stop, remove, and update the Repomanager container. Includes deployment configurations for both bridge and host network modes. ```bash docker stop repomanager docker rm -f repomanager docker system prune -a -f ``` ```bash # Bridge mode docker run -d --restart unless-stopped --name repomanager \ -e FQDN=repomanager.example.com \ -e MAX_UPLOAD_SIZE=32M \ -p 8080:8080 \ -v /etc/localtime:/etc/localtime:ro \ -v /var/lib/docker/volumes/repomanager-data:/var/lib/repomanager \ -v /var/lib/docker/volumes/repomanager-repo:/home/repo \ lbr38/repomanager: ``` ```bash # Host mode docker run -d --restart unless-stopped --name repomanager --network=host \ -e FQDN=repomanager.example.com \ -e MAX_UPLOAD_SIZE=32M \ -e NGINX_LISTEN_PORT=8080 \ -v /etc/localtime:/etc/localtime:ro \ -v /var/lib/docker/volumes/repomanager-data:/var/lib/repomanager \ -v /var/lib/docker/volumes/repomanager-repo:/home/repo \ lbr38/repomanager: ``` -------------------------------- ### Run Repomanager Docker Container (Bridge Network) Source: https://github.com/lbr38/repomanager/wiki/01.-Installation-and-update This command runs the Repomanager Docker container in bridge network mode. It configures essential environment variables like FQDN and MAX_UPLOAD_SIZE, maps ports, and sets up persistent volumes for data and repositories. Ensure Docker is installed and running. ```bash docker run -d --restart unless-stopped --name repomanager \ -e FQDN=repomanager.example.com \ -e MAX_UPLOAD_SIZE=32M \ -p 8080:8080 \ -v /etc/localtime:/etc/localtime:ro \ -v /var/lib/docker/volumes/repomanager-data:/var/lib/repomanager \ -v /var/lib/docker/volumes/repomanager-repo:/home/repo \ lbr38/repomanager:latest ``` -------------------------------- ### Secure Connector with Custom SSL Options - PHP Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/socket/README.md Provides an example of creating a SecureConnector with custom SSL context options, such as disabling peer verification. This allows for more granular control over the TLS connection setup. ```php $secureConnector = new React\Socket\SecureConnector($dnsConnector, null, array( 'verify_peer' => false, 'verify_peer_name' => false )); ``` -------------------------------- ### Initialize WritableResourceStream Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/stream/README.md Demonstrates basic instantiation and usage of WritableResourceStream with a standard output stream. ```php $stream = new WritableResourceStream(STDOUT); $stream->write('hello!'); $stream->end(); ``` -------------------------------- ### Configure Nginx Reverse Proxy for Repomanager Source: https://github.com/lbr38/repomanager/wiki/01.-Installation-and-update This Nginx configuration sets up HTTP-to-HTTPS redirection, SSL termination, security headers, and proxying to the Repomanager backend. It includes logging exclusions for specific paths and client upload size limits. ```nginx map $request_uri $loggable { /ajax/controller.php 0; default 1; } server { listen :80; server_name ; access_log /var/log/nginx/_access.log combined if=$loggable; error_log /var/log/nginx/_error.log; return 301 https://$server_name$request_uri; } server { listen :443 ssl; server_name ; ssl_certificate ; ssl_certificate_key ; access_log /var/log/nginx/_ssl_access.log combined if=$loggable; error_log /var/log/nginx/_ssl_error.log; client_max_body_size 32M; add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always; add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; fastcgi_hide_header X-Powered-By; location / { proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port 443; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 86400; proxy_pass http://repomanager_docker; } } ``` -------------------------------- ### Check Repomanager Docker Container Logs Source: https://github.com/lbr38/repomanager/wiki/14.-Migrations This command streams the logs of the Repomanager Docker container in real-time. It is crucial for monitoring the migration process during the 5.0.0 upgrade, allowing users to identify the start and completion of the migration and any potential errors. ```bash docker logs -f repomanager ``` -------------------------------- ### Run Repomanager Docker Container (Host Network) Source: https://github.com/lbr38/repomanager/wiki/01.-Installation-and-update This command runs the Repomanager Docker container using the host network mode, which is recommended for public hosts. It bypasses Docker's network isolation and uses the host's firewall rules. Environment variables and persistent volumes are configured similarly to bridge mode, with an additional option for NGINX_LISTEN_PORT. ```bash docker run -d --restart unless-stopped --name repomanager --network=host \ -e FQDN=repomanager.example.com \ -e MAX_UPLOAD_SIZE=32M \ -e NGINX_LISTEN_PORT=8080 \ -v /etc/localtime:/etc/localtime:ro \ -v /var/lib/docker/volumes/repomanager-data:/var/lib/repomanager \ -v /var/lib/docker/volumes/repomanager-repo:/home/repo \ lbr38/repomanager:latest ``` -------------------------------- ### Create DNS Connector and Connect - PHP Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/socket/README.md Demonstrates how to instantiate a DnsConnector with a TCP connector and DNS resolver, then establish a connection to a specified host and port. It also shows how to handle the connection promise. ```php $dnsResolverFactory = new React\Dns\Resolver\Factory(); $dns = $dnsResolverFactory->createCached('8.8.8.8'); $dnsConnector = new React\Socket\DnsConnector($tcpConnector, $dns); $dnsConnector->connect('www.google.com:80')->then(function (React\Socket\ConnectionInterface $connection) { $connection->write('...'); $connection->end(); }); ``` -------------------------------- ### Run Test Suite (Bash) Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/cache/README.md Details the command to execute the project's test suite using PHPUnit from the project's root directory. ```bash vendor/bin/phpunit ``` -------------------------------- ### Configure Write Chunk Size Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/stream/README.md Demonstrates how to initialize the stream with a custom write chunk size, controlling the maximum bytes written per operation. ```php $stream = new WritableResourceStream(STDOUT, null, null, 8192); ``` -------------------------------- ### Instantiate SecureServer with PEM Certificate Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/socket/README.md Demonstrates how to create a SecureServer instance using a PEM encoded certificate file. The certificate is loaded when an incoming connection initializes its TLS context. ```php $server = new React\Socket\TcpServer(8000); $server = new React\Socket\SecureServer($server, null, array( 'local_cert' => 'server.pem' )); ``` -------------------------------- ### Create a Socket Server and Client with ReactPHP Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/socket/README.md Demonstrates how to initialize a SocketServer to accept connections and a Connector to establish outgoing connections. The server responds to incoming data by closing the connection, while the client pipes the server output to standard output. ```php $socket = new React\Socket\SocketServer('127.0.0.1:8080'); $socket->on('connection', function (React\Socket\ConnectionInterface $connection) { $connection->write("Hello " . $connection->getRemoteAddress() . "!\n"); $connection->write("Welcome to this amazing server!\n"); $connection->write("Here's a tip: don't say anything.\n"); $connection->on('data', function ($data) use ($connection) { $connection->close(); }); }); ``` ```php $connector = new React\Socket\Connector(); $connector->connect('127.0.0.1:8080')->then(function (React\Socket\ConnectionInterface $connection) { $connection->pipe(new React\Stream\WritableResourceStream(STDOUT)); $connection->write("Hello World!\n"); }, function (Exception $e) { echo 'Error: ' . $e->getMessage() . PHP_EOL; }); ``` -------------------------------- ### Install PSR-7 Message Implementation using Composer Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/guzzlehttp/psr7/README.md This command installs the guzzlehttp/psr7 package using Composer, a dependency manager for PHP. It is the primary method for integrating this library into your project. ```shell composer require guzzlehttp/psr7 ``` -------------------------------- ### Establish Streaming Connections with Connector Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/socket/README.md Demonstrates how to initialize the Connector and establish various types of connections including default TCP, secure TLS, and local Unix domain sockets using URI schemes. ```php $connector = new React\Socket\Connector(); $connector->connect($uri)->then(function (React\Socket\ConnectionInterface $connection) { $connection->write('...'); $connection->end(); }, function (Exception $e) { echo 'Error: ' . $e->getMessage() . PHP_EOL; }); ``` ```php $connector->connect('www.google.com:80')->then(function (React\Socket\ConnectionInterface $connection) { $connection->write('...'); $connection->end(); }); ``` ```php $connector->connect('tls://www.google.com:443')->then(function (React\Socket\ConnectionInterface $connection) { $connection->write('...'); $connection->end(); }); ``` ```php $connector->connect('unix:///tmp/demo.sock')->then(function (React\Socket\ConnectionInterface $connection) { $connection->write('...'); $connection->end(); }); ``` -------------------------------- ### POST /api/v2/host/registering Source: https://context7.com/lbr38/repomanager/llms.txt Register a new client host with the system. ```APIDOC ## POST /api/v2/host/registering ### Description Register a new host to receive a unique ID and authentication token. ### Method POST ### Endpoint https://repomanager.example.com/api/v2/host/registering ### Request Body - **hostname** (string) - Required - FQDN of the host. - **ip** (string) - Required - IP address of the host. ### Response #### Success Response (200) - **results** (object) - Contains 'id' and 'token'. ``` -------------------------------- ### Retrieve cached items using get() Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/cache/README.md The get() method retrieves a value from the cache asynchronously. It returns a Promise that resolves with the cached value or a default value if the key is missing or expired. ```php $cache ->get('foo') ->then('var_dump'); ``` -------------------------------- ### Emit an Event in PHP Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/evenement/evenement/README.md This code demonstrates how to trigger an event ('user.created') and pass data (a User object) to its listeners. The second argument is an array containing the arguments to be passed to the listener callbacks. ```php emit('user.created', [$user]); ``` -------------------------------- ### Instantiate SecureServer with Encrypted Private Key Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/socket/README.md Shows how to configure the SecureServer when the private key is encrypted with a passphrase. The 'passphrase' option is added to the TLS context options. ```php $server = new React\Socket\TcpServer(8000); $server = new React\Socket\SecureServer($server, null, array( 'local_cert' => 'server.pem', 'passphrase' => 'secret' )); ``` -------------------------------- ### Fallback Get and Set with ArrayCache (PHP) Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/cache/README.md Expands on the fallback get pattern by adding the functionality to cache the value after it has been fetched from the data source. This ensures that subsequent requests for the same data will be served from the cache. ```php $cache ->get('foo') ->then(function ($result) { if ($result === null) { return $this->getAndCacheFooFromDb(); } return $result; }) ->then('var_dump'); public function getAndCacheFooFromDb() { return $this->db ->get('foo') ->then(array($this, 'cacheFooFromDb')); } public function cacheFooFromDb($foo) { $this->cache->set('foo', $foo); return $foo; } ``` -------------------------------- ### Establish Streaming Connection with ConnectorInterface (PHP) Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/socket/README.md Demonstrates how to use the connect() method of the ConnectorInterface to establish a streaming connection to a given URI. It shows how to handle both successful connections and connection failures using Promises. The returned Promise must be cancellable. ```php $connector->connect('google.com:443')->then( function (React\Socket\ConnectionInterface $connection) { // connection successfully established }, function (Exception $error) { // failed to connect due to $error } ); $promise = $connector->connect($uri); $promise->cancel(); ``` -------------------------------- ### Get and Modify PSR-7 Response Body Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/psr/http-message/docs/PSR7-Usage.md Illustrates how to get the body stream from a PSR-7 response, perform operations on it (like writing), and then optionally replace the response body with the modified stream. This approach is recommended for clarity and preventing errors. ```php $body = $response->getBody(); // operations on body, eg. read, write, seek // ... // replacing the old body $response->withBody($body); // this last statement is optional as we working with objects // in this case the "new" body is same with the "old" one // the $body variable has the same value as the one in $request, only the reference is passed ``` -------------------------------- ### Instantiate and Use ReadableResourceStream with STDIN Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/stream/README.md Demonstrates how to create a ReadableResourceStream instance using STDIN and attach event listeners for 'data' and 'end' events. This is useful for processing input streams in a non-blocking manner. ```php $stream = new ReadableResourceStream(STDIN); $stream->on('data', function ($chunk) { echo $chunk; }); $stream->on('end', function () { echo 'END'; }); ``` -------------------------------- ### GET /api/v2/repo/{id}/ Source: https://context7.com/lbr38/repomanager/llms.txt Retrieve all snapshots associated with a specific repository ID. ```APIDOC ## GET /api/v2/repo/{id}/ ### Description List all snapshots for a specific repository by its ID. ### Method GET ### Endpoint https://repomanager.example.com/api/v2/repo/{id}/ ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the repository. ### Response #### Success Response (200) - **results** (array) - List of snapshots with Id, Date, Time, and Env. #### Response Example { "return": 201, "results": [ { "Id": "45", "Date": "2024-01-15", "Time": "14:30:00", "Env": "prod" } ] } ``` -------------------------------- ### Resolve hostnames asynchronously in PHP Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/dns/README.md Demonstrates how to initialize a DNS resolver using system configuration and perform an asynchronous hostname resolution. The resolver returns a promise that resolves to an IP address. ```php $config = React\Dns\Config\Config::loadSystemConfigBlocking(); if (!$config->nameservers) { $config->nameservers[] = '8.8.8.8'; } $factory = new React\Dns\Resolver\Factory(); $dns = $factory->create($config); $dns->resolve('igor.io')->then(function ($ip) { echo "Host: $ip\n"; }); ``` -------------------------------- ### Configure Network and Security Settings Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/jumbojett/openid-connect-php/README.md Shows how to configure network and security-related options for the OpenID Connect client. This includes setting up an HTTP proxy for network requests and specifying a certificate path for secure communication. ```php // Configure a proxy $oidc->setHttpProxy("http://my.proxy.com:80/"); // Configure a cert $oidc->setCertPath("/path/to/my.cert"); ``` -------------------------------- ### GET /api/v2/source/ Source: https://context7.com/lbr38/repomanager/llms.txt Retrieves a list of all configured source repositories that serve as upstream mirrors. ```APIDOC ## GET /api/v2/source/ ### Description List all available source repositories. ### Method GET ### Endpoint /api/v2/source/ ### Response #### Success Response (200) - **results** (array) - List of repository objects #### Response Example { "results": [ { "name": "nginx-official", "type": "deb" }, { "name": "epel", "type": "rpm" } ] } ``` -------------------------------- ### GET /api/v2/profile Source: https://context7.com/lbr38/repomanager/llms.txt Retrieves configuration profiles, including package exclusions and repository assignments. ```APIDOC ## GET /api/v2/profile ### Description Retrieves a list of available host profiles or specific configuration details for a profile. ### Method GET ### Endpoint https://repomanager.example.com/api/v2/profile/{profile_name} ### Parameters #### Path Parameters - **profile_name** (string) - Optional - The name of the profile to retrieve ### Response #### Success Response (201) - **return** (integer) - Status code - **results** (array/object) - Profile configuration data ``` -------------------------------- ### Handle Unix Domain Socket Connections (PHP) Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/socket/README.md Sets up an event listener for the 'connection' event on a UnixServer. When a new client connects, it echoes a message and writes 'hello there!' to the connection. Requires a ReactSocketConnectionInterface. ```php $server->on('connection', function (React\Socket\ConnectionInterface $connection) { echo 'New connection' . PHP_EOL; $connection->write('hello there!' . PHP_EOL); … }); ``` -------------------------------- ### Add an Event Listener in PHP Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/evenement/evenement/README.md This code shows how to attach a listener function to a specific event ('user.created'). The provided closure will be executed when the 'user.created' event is emitted. It utilizes a closure that accepts a User object and uses a logger instance. ```php on('user.created', function (User $user) use ($logger) { $logger->log(sprintf("User '%s' was created.", $user->getLogin())); }); ``` -------------------------------- ### GET /api/v2/repo/ Source: https://context7.com/lbr38/repomanager/llms.txt Retrieve a list of all available repositories. Supports filtering via client-side processing. ```APIDOC ## GET /api/v2/repo/ ### Description Retrieve all repositories managed by the system. ### Method GET ### Endpoint https://repomanager.example.com/api/v2/repo/ ### Response #### Success Response (200) - **results** (array) - List of repository objects containing Id, Name, Type, and metadata. #### Response Example { "return": 201, "results": [ { "Id": "12", "Name": "nginx", "Type": "mirror" } ] } ``` -------------------------------- ### GET /api/v2/source/{type}/{name} Source: https://context7.com/lbr38/repomanager/llms.txt Retrieves detailed information about a specific source repository by its type and name. ```APIDOC ## GET /api/v2/source/{type}/{name} ### Description Get details for a specific source repository. ### Method GET ### Endpoint /api/v2/source/{type}/{name} ### Parameters #### Path Parameters - **type** (string) - Required - The repository type (e.g., deb, rpm) - **name** (string) - Required - The unique name of the repository ### Response #### Success Response (200) - **name** (string) - Repository name - **url** (string) - Upstream URL #### Response Example { "name": "debian-official", "type": "deb", "url": "http://deb.debian.org/debian" } ``` -------------------------------- ### Resolve domain names and handle promises in PHP Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/dns/README.md Explains the usage of the resolve() method to obtain an IP address and demonstrates how to cancel a pending DNS query using the returned promise. ```php $resolver->resolve('reactphp.org')->then(function ($ip) { echo 'IP for reactphp.org is ' . $ip . PHP_EOL; }); // Cancelling a query $promise = $resolver->resolve('reactphp.org'); $promise->cancel(); ``` -------------------------------- ### Pipe file streams Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/stream/README.md Demonstrates piping data from a source file to a destination file using React Stream's resource stream wrappers. ```php $source = new React\Stream\ReadableResourceStream(fopen('source.txt', 'r')); $dest = new React\Stream\WritableResourceStream(fopen('destination.txt', 'w')); $source->pipe($dest); ``` -------------------------------- ### Execute PHPUnit test suite Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/stream/README.md Runs the project's unit and integration tests using PHPUnit. Includes options to run the full suite or exclude specific test groups such as those requiring an internet connection. ```bash vendor/bin/phpunit ``` ```bash vendor/bin/phpunit --exclude-group internet ``` -------------------------------- ### GET /api/v2/host/status Source: https://context7.com/lbr38/repomanager/llms.txt Allows registered client hosts to report their current status or retrieve configuration profiles using host-specific credentials. ```APIDOC ## GET /api/v2/host/status ### Description Endpoint for registered hosts to report status or retrieve configuration profiles. ### Method GET ### Endpoint /api/v2/host/status ### Parameters #### Query Parameters - **Authorization** (header) - Required - Host : ### Request Example curl -H "Authorization: Host :" https://repomanager.example.com/api/v2/host/status ### Response #### Success Response (200) - **status** (string) - Current operational status of the host. #### Response Example { "status": "OK", "last_checkin": "2023-10-27T10:00:00Z" } ``` -------------------------------- ### Retrieve Server Listening Address Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/socket/README.md Retrieves the full URI the server is currently listening on. Includes an example for extracting the port number from the address string. ```php $address = $socket->getAddress(); echo 'Server listening on ' . $address . PHP_EOL; ``` ```php $address = $socket->getAddress(); $port = parse_url($address, PHP_URL_PORT); echo 'Server listening on port ' . $port . PHP_EOL; ``` -------------------------------- ### Run event loop execution Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/event-loop/README.md The run method executes the event loop until no tasks remain. It is the primary method for starting the application's event-driven logic. ```php $loop->run(); ``` -------------------------------- ### Create a Promise with Resolver and Canceller in PHP Source: https://github.com/lbr38/repomanager/blob/devel/www/libs/vendor/react/promise/README.md Demonstrates how to instantiate a React Promise using a resolver function to handle asynchronous logic and an optional canceller function to manage lifecycle termination. ```php $resolver = function (callable $resolve, callable $reject) { $resolve($awesomeResult); }; $canceller = function () { throw new Exception('Promise cancelled'); }; $promise = new React\Promise\Promise($resolver, $canceller); ```