### Initialize QuaggaJS with Configuration Source: https://github.com/slims/slims9_bulian/blob/master/js/quaggaJS/README.md Example of initializing QuaggaJS with specific configurations for the input stream and decoder. It includes a callback function to handle the initialization result and start the detection process. ```javascript Quagga.init({ inputStream : { name : "Live", type : "LiveStream", target: document.querySelector('#yourElement') // Or '#yourElement' (optional) }, decoder : { readers : ["code_128_reader"] } }, function(err) { if (err) { console.log(err); return } console.log("Initialization finished. Ready to start"); Quagga.start(); }); ``` -------------------------------- ### Basic Carbon PHP Usage After Composer Installation Source: https://github.com/slims/slims9_bulian/blob/master/lib/nesbot/carbon/readme.md A simple example demonstrating how to include the Composer autoloader and use the Carbon::now() method to display the current date and time after installing the package via Composer. ```php request('GET', 'https://api.github.com/repos/guzzle/guzzle'); echo $response->getStatusCode(); // 200 echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8' echo $response->getBody(); // '{"id": 1420053, "name": "guzzle", ...}' // Send an asynchronous request. $request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org'); $promise = $client->sendAsync($request)->then(function ($response) { echo 'I completed! ' . $response->getBody(); }); $promise->wait(); ``` -------------------------------- ### Install PHP Gettext using Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/lang/gettext/gettext/README.md This snippet shows how to install the Gettext library using Composer, the dependency manager for PHP. Ensure you have Composer installed and configured. ```bash composer require gettext/gettext ``` -------------------------------- ### Setup Multiple Plyr Players with Static Method Source: https://github.com/slims/slims9_bulian/blob/master/js/plyr/readme.md Sets up multiple Plyr player instances using the static `setup` method. This method accepts a string selector, NodeList, or an Array of elements, simplifying the initialization of multiple players. ```javascript const players = Plyr.setup('.js-player'); ``` -------------------------------- ### Basic ZipStream PHP Usage Example Source: https://github.com/slims/slims9_bulian/blob/master/lib/maennchen/zipstream-php/guides/index.rst This example demonstrates the fundamental usage of ZipStream PHP to create a zip archive. It includes enabling HTTP headers, adding files with direct content, from a local path, and from a stream resource, and finally finishing the zip stream. ```php // Autoload the dependencies require 'vendor/autoload.php'; // enable output of HTTP headers $options = new ZipStream\Option\Archive(); $options->setSendHttpHeaders(true); // create a new zipstream object $zip = new ZipStream\ZipStream('example.zip', $options); // create a file named 'hello.txt' $zip->addFile('hello.txt', 'This is the contents of hello.txt'); // add a file named 'some_image.jpg' from a local file 'path/to/image.jpg' $zip->addFileFromPath('some_image.jpg', 'path/to/image.jpg'); // add a file named 'goodbye.txt' from an open stream resource $fp = tmpfile(); fwrite($fp, 'The quick brown fox jumped over the lazy dog.'); rewind($fp); $zip->addFileFromStream('goodbye.txt', $fp); fclose($fp); // finish the zip stream $zip->finish(); ``` -------------------------------- ### Example cURL Request for Popular Bibliographic Items Source: https://context7.com/slims/slims9_bulian/llms.txt Demonstrates how to retrieve popular bibliographic items using a cURL command. This example shows the HTTP GET request to the '/api/biblio/popular' endpoint and specifies the expected JSON response format. ```bash curl -X GET "http://your-slims-server/api/biblio/popular" \ -H "Accept: application/json" ``` -------------------------------- ### Install QuaggaJS using Bower Source: https://github.com/slims/slims9_bulian/blob/master/js/quaggaJS/README.md Provides the command to install QuaggaJS using Bower, a package manager for the web. This is an alternative installation method for front-end projects. ```bash > bower install quagga ``` -------------------------------- ### Install QuaggaJS using npm Source: https://github.com/slims/slims9_bulian/blob/master/js/quaggaJS/README.md Demonstrates how to install the QuaggaJS library using npm, the Node Package Manager. After installation, it shows how to import the library into your project using ES6 module syntax or CommonJS. ```bash > npm install quagga ``` ```javascript import Quagga from 'quagga'; // ES6 const Quagga = require('quagga').default; // Common JS (important: default) ``` -------------------------------- ### Install Constant-Time Encoding Library with Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/paragonie/constant_time_encoding/README.md This command installs the library using Composer, the dependency manager for PHP. It ensures the library and its dependencies are correctly set up in your project. ```sh composer require paragonie/constant_time_encoding ``` -------------------------------- ### Install PHP Scanner using Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/lang/gettext/php-scanner/README.md This command installs the PHP Scanner library using Composer, a dependency manager for PHP. Ensure Composer is installed globally on your system. ```bash composer require gettext/php-scanner ``` -------------------------------- ### Player Getters Example (JavaScript) Source: https://github.com/slims/slims9_bulian/blob/master/js/plyr/readme.md Illustrates how to use getter properties to retrieve player information, including current volume, playback time, and fullscreen status. ```javascript player.volume; // 0.5; player.currentTime; // 10 player.fullscreen.active; // false; ``` -------------------------------- ### Install ZipStream-PHP with Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/maennchen/zipstream-php/README.md This command adds the ZipStream-PHP package as a dependency to your project using Composer. Ensure you have Composer installed and are in your project's root directory. ```bash composer require maennchen/zipstream-php ``` -------------------------------- ### Install Carbon PHP Package with Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/nesbot/carbon/readme.md Provides instructions for installing the Carbon PHP package using Composer, the standard dependency manager for PHP. It includes the command-line instruction and the corresponding entry for the composer.json file. ```bash $ composer require nesbot/carbon ``` ```json { "require": { "nesbot/carbon": "^2.16" } } ``` -------------------------------- ### Install PHPComplex using Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/markbaker/complex/README.md This command installs the PHPComplex library version 1.0 or higher using Composer, the dependency manager for PHP. Ensure Composer is installed and available in your PATH. ```shell composer require markbaker/complex:^1.0 ``` -------------------------------- ### Install Composer Dependencies for SLiMS Source: https://context7.com/slims/slims9_bulian/llms.txt Installs Composer and its dependencies for the SLiMS application. It downloads the Composer installer, executes it to install Composer globally, and then installs project dependencies, optimizing the autoloader for production. ```dockerfile RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer RUN composer install --no-dev --optimize-autoloader ``` -------------------------------- ### Player Setters Example (JavaScript) Source: https://github.com/slims/slims9_bulian/blob/master/js/plyr/readme.md Demonstrates how to use setter properties to control player state, such as setting the volume to 50% or seeking to a specific timestamp. ```javascript player.volume = 0.5; // Sets volume at 50% player.currentTime = 10; // Seeks to 10 seconds ``` -------------------------------- ### Carbon PHP Date and Time Manipulation Examples Source: https://github.com/slims/slims9_bulian/blob/master/lib/nesbot/carbon/readme.md Demonstrates various functionalities of the Carbon PHP package, including getting current times, manipulating dates and times (adding, subtracting), performing date comparisons, formatting dates into different string representations (RFC2822, ISO 8601), and calculating age. It also shows how to set test instances for predictable testing. ```php toDateTimeString()); printf("Right now in Vancouver is %s", Carbon::now('America/Vancouver')); //implicit __toString() $tomorrow = Carbon::now()->addDay(); $lastWeek = Carbon::now()->subWeek(); $nextSummerOlympics = Carbon::createFromDate(2016)->addYears(4); $officialDate = Carbon::now()->toRfc2822String(); $howOldAmI = Carbon::createFromDate(1975, 5, 21)->age; $noonTodayLondonTime = Carbon::createFromTime(12, 0, 0, 'Europe/London'); $internetWillBlowUpOn = Carbon::create(2038, 01, 19, 3, 14, 7, 'GMT'); // Don't really want this to happen so mock now Carbon::setTestNow(Carbon::createFromDate(2000, 1, 1)); // comparisons are always done in UTC if (Carbon::now()->gte($internetWillBlowUpOn)) { die(); } // Phew! Return to normal behaviour Carbon::setTestNow(); if (Carbon::now()->isWeekend()) { echo 'Party!'; } // Over 200 languages (and over 500 regional variants) supported: echo Carbon::now()->subMinutes(2)->diffForHumans(); // '2 minutes ago' echo Carbon::now()->subMinutes(2)->locale('zh_CN')->diffForHumans(); // '2分钟前' echo Carbon::parse('2019-07-23 14:51')->isoFormat('LLLL'); // 'Tuesday, July 23, 2019 2:51 PM' echo Carbon::parse('2019-07-23 14:51')->locale('fr_FR')->isoFormat('LLLL'); // 'mardi 23 juillet 2019 14:51' // ... but also does 'from now', 'after' and 'before' // rolling up to seconds, minutes, hours, days, months, years $daysSinceEpoch = Carbon::createFromTimestamp(0)->diffInDays(); ``` -------------------------------- ### Install PHPMatrix Functions using Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/markbaker/matrix/README.md This command installs the PHPMatrixFunctions library, which should be used for procedural calls from version 3.0 onwards. This replaces the direct dependency on the main PHPMatrix library for functions. ```shell composer require markbaker/matrix-functions:^1.0 ``` -------------------------------- ### Bash: Install Guzzle via Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/guzzlehttp/guzzle/README.md Installs the Guzzle HTTP client package using Composer, the dependency manager for PHP. This command should be run in the root directory of your PHP project. ```bash composer require guzzlehttp/guzzle ``` -------------------------------- ### Add mbstring extension using Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/maennchen/zipstream-php/guides/index.rst If Composer installation fails due to a missing 'mbstring' extension, this command installs a polyfill for it. Alternatively, you can install the mbstring extension directly in your PHP environment. ```sh composer require symfony/polyfill-mbstring ``` -------------------------------- ### Install Symfony Translation Component with Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/symfony/translation/README.md This command installs the Symfony Translation component using Composer. It is a prerequisite for using the translation features in your Symfony application. ```bash composer require symfony\/translation ``` -------------------------------- ### Install ramsey/uuid with Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/uuid/README.md This snippet shows the Composer command to install the ramsey/uuid library and add it as a dependency to your PHP project. Composer handles dependency management for PHP. ```bash composer require ramsey/uuid ``` -------------------------------- ### Install PHPComplexFunctions using Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/markbaker/complex/README.md This command installs the PHPComplexFunctions library version 3.0 or higher using Composer. This is recommended for procedural calls, replacing the older `markbaker/complex` dependency for such use cases. ```shell composer require markbaker/complex-functions:^3.0 ``` -------------------------------- ### Example cURL Request for Latest Bibliographic Items Source: https://context7.com/slims/slims9_bulian/llms.txt Shows how to fetch the latest bibliographic items using cURL. This example illustrates the GET request to the '/api/biblio/latest' endpoint, expecting a JSON array as output. ```bash curl -X GET "http://your-slims-server/api/biblio/latest" \ -H "Accept: application/json" ``` -------------------------------- ### Basic ZipStream-PHP Usage Example Source: https://github.com/slims/slims9_bulian/blob/master/lib/maennchen/zipstream-php/README.md This PHP code demonstrates the basic usage of the ZipStream-PHP library. It includes enabling HTTP headers, creating a zip archive named 'example.zip', adding a text file with inline content, adding a file from a local path, and finishing the zip stream. ```php // Autoload the dependencies require 'vendor/autoload.php'; // enable output of HTTP headers $options = new ZipStream\Option\Archive(); $options->setSendHttpHeaders(true); // create a new zipstream object $zip = new ZipStream\ZipStream('example.zip', $options); // create a file named 'hello.txt' $zip->addFile('hello.txt', 'This is the contents of hello.txt'); // add a file named 'some_image.jpg' from a local file 'path/to/image.jpg' $zip->addFileFromPath('some_image.jpg', 'path/to/image.jpg'); // finish the zip stream $zip->finish(); ``` -------------------------------- ### Get Header as Array using PHP Source: https://github.com/slims/slims9_bulian/blob/master/lib/psr/http-message/docs/PSR7-Usage.md Shows how to retrieve the value(s) of an HTTP header as an array of strings. This method works for both request and response objects. Requires a PSR-7 implementation. ```php // getting value from request headers $request->getHeader('Content-Type'); // will return: ["text/html", "charset=UTF-8"] // getting value from response headers $response->getHeader('My-Custom-Header'); // will return: ["My Custom Message", "The second message"] ``` -------------------------------- ### Quagga.init() Source: https://github.com/slims/slims9_bulian/blob/master/js/quaggaJS/README.md Initializes the QuaggaJS library with a given configuration and invokes a callback upon completion. It may request camera access if live detection is configured. ```APIDOC ## Quagga.init(config, callback) ### Description Initializes the library for a given configuration `config` and invokes the `callback(err)` when bootstrapping is finished. Requests camera access if real-time detection is configured. The `err` parameter in the callback provides details about any issues encountered during initialization, such as browser API support or user permission denial. If no target is specified, QuaggaJS defaults to an element matching the CSS selector `#interactive.viewport`. ### Method `Quagga.init() ### Parameters #### Arguments - **config** (object) - Configuration object for initialization. See QuaggaJS documentation for detailed options. - **callback** (function) - A function to be called after initialization. It receives an error object `err` if initialization fails. #### Request Body (Example for config) ```json { "inputStream": { "name": "Live", "type": "LiveStream", "target": "#yourElement" /* Or a DOM node */ }, "decoder": { "readers": ["code_128_reader"] } } ``` ### Request Example ```javascript Quagga.init({ inputStream : { name : "Live", type : "LiveStream", target: document.querySelector('#yourElement') // Or '#yourElement' (optional) }, decoder : { readers : ["code_128_reader"] } }, function(err) { if (err) { console.log(err); return } console.log("Initialization finished. Ready to start"); Quagga.start(); }); ``` ### Response #### Success Response (Callback invoked with err = null) - **err** (object | null) - Null if initialization is successful, otherwise an error object detailing the cause. ``` -------------------------------- ### Get Header as Comma-Separated String using PHP Source: https://github.com/slims/slims9_bulian/blob/master/lib/psr/http-message/docs/PSR7-Usage.md Demonstrates retrieving the value of an HTTP header as a single, comma-separated string. This method is available for both request and response objects. Requires a PSR-7 implementation. ```php // getting value from request headers $request->getHeaderLine('Content-Type'); // will return: "text/html; charset=UTF-8" // getting value from response headers $response->getHeaderLine('My-Custom-Header'); // will return: "My Custom Message; The second message" ``` -------------------------------- ### Generate QR Code to PNG File Source: https://github.com/slims/slims9_bulian/blob/master/lib/bacon/bacon-qr-code/README.md Generates a QR code for the given text and saves it as a PNG file. This example utilizes the ImagickImageBackEnd for rendering. Ensure the Imagick PHP extension is installed. ```php use BaconQrCode\Renderer\ImageRenderer; use BaconQrCode\Renderer\Image\ImagickImageBackEnd; use BaconQrCode\Renderer\RendererStyle\RendererStyle; use BaconQrCode\Writer; $renderer = new ImageRenderer( new RendererStyle(400), new ImagickImageBackEnd() ); $writer = new Writer($renderer); $writer->writeFile('Hello World!', 'qrcode.png'); ``` -------------------------------- ### Expose Web Server Port and Define Entrypoint/Command Source: https://context7.com/slims/slims9_bulian/llms.txt Defines the network port exposed by the container and specifies the entrypoint script and default command to run when the container starts. It exposes port 80 for HTTP traffic and sets 'entrypoint.sh' as the entrypoint, with 'apache2-foreground' as the default command to keep the Apache web server running. ```dockerfile EXPOSE 80 ENTRYPOINT ["entrypoint.sh"] CMD ["apache2-foreground"] ``` -------------------------------- ### Get HTTP Message Body Contents using PHP Source: https://github.com/slims/slims9_bulian/blob/master/lib/psr/http-message/docs/PSR7-Usage.md Illustrates how to read the entire content of an HTTP message body stream into a string. It is crucial to rewind the stream before reading to ensure all content is captured. Requires a PSR-7 implementation. ```php $body = $response->getBody(); $body->rewind(); // or $body->seek(0); $bodyText = $body->getContents(); ``` -------------------------------- ### Manipulate HTTP Message Body (Separate Get) using PHP Source: https://github.com/slims/slims9_bulian/blob/master/lib/psr/http-message/docs/PSR7-Usage.md Demonstrates obtaining the HTTP message body as a stream object, performing operations on it, and then re-associating it with the message. This method is recommended for clarity and preventing errors. Requires a PSR-7 implementation. ```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 ``` -------------------------------- ### Receiving Progress Information During MySQL Dump (PHP) Source: https://github.com/slims/slims9_bulian/blob/master/lib/mysqldump-php/README.md This example shows how to get progress updates during the database dump operation by registering a callable function with `setInfoHook`. The provided callback function is designed to receive information about the dump progress, such as table names and row counts, and can be used for logging or UI feedback. ```php $dumper->setInfoHook(function($object, $info) { if ($object === 'table') { echo $info['name'], $info['rowCount']; }); ``` -------------------------------- ### SLiMS Configuration Management (PHP) Source: https://context7.com/slims/slims9_bulian/llms.txt Illustrates how to manage application configuration using the SLiMS Config class. It shows retrieving settings with defaults, creating configuration files from samples, and handling environment-specific configurations. Database configuration is auto-created if missing. ```php // Configuration using SLiMS\Config class use SLiMS\Config; // Get configuration instance $config = Config::getInstance(); // Retrieve configuration values with defaults $base_url = $config->get('url.base', 'http://localhost'); $timezone = config('timezone', 'Asia/Jakarta'); // Database configuration is auto-created from sample if missing Config::create('database', function($filename) { $source = file_get_contents(SB.'config'.DS.'database.sample.php'); $params = [ ['_DB_HOST_', '_DB_NAME_', '_DB_PORT_', '_DB_USER_', '_DB_PASSWORD_'], [DB_HOST, DB_NAME, DB_PORT, DB_USERNAME, DB_PASSWORD], $source ]; return str_replace(...$params); }); // Create config files from samples if they don't exist Config::createFromSampleIfNotExists(['csp', 'auth']); // Environment configuration define('ENVIRONMENT', $env ?? 'unavailable'); if (ENVIRONMENT === 'unavailable' && file_exists(__DIR__ . '/config/database.php')) { header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); exit(1); } // Global system configuration array example $sysconf['session_timeout'] = 7200; // seconds $sysconf['default_lang'] = 'en_US'; $sysconf['max_upload'] = intval(ini_get('upload_max_filesize')) * 1024; $sysconf['allowed_images'] = ['.jpeg', '.jpg', '.gif', '.png']; // Load settings from database (overrides defaults) utility::loadSettings($dbs); ``` -------------------------------- ### Run QuaggaJS Unit Tests (Console) Source: https://github.com/slims/slims9_bulian/blob/master/js/quaggaJS/README.md Command-line instructions for installing dependencies and running unit tests for QuaggaJS. Tests are executed using Karma, Mocha, Chai, and SinonJS, with coverage reports generated in the 'coverage/' folder. ```bash > npm install > npm run test ``` -------------------------------- ### Install myclabs/php-enum via Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/myclabs/php-enum/README.md This command installs the myclabs/php-enum library using Composer, making it available for use in your PHP project. Ensure Composer is installed and accessible in your environment. ```bash composer require myclabs/php-enum ``` -------------------------------- ### Initialize HTML5 Video Player with Plyr Source: https://github.com/slims/slims9_bulian/blob/master/js/plyr/readme.md This code snippet demonstrates how to set up an HTML5 video player using Plyr. It includes basic video sources, poster image, captions, and essential attributes like 'controls' and 'playsinline'. This setup requires the Plyr JavaScript library to be included in your project. ```html ``` -------------------------------- ### SLiMS Plugin System Integration (PHP) Source: https://context7.com/slims/slims9_bulian/llms.txt Demonstrates how to load, execute, and register hooks within the SLiMS plugin system. It covers plugin loading, hook execution for content and custom routes, and registering custom functionality via callbacks. Also includes an example of a plugin's metadata and a system configuration for max plugin upload size. ```php // Load and execute plugins require 'lib/autoload.php'; // Load all enabled plugins \SLiMS\Plugins::getInstance()->loadPlugins(); // Execute plugin hook before content load \SLiMS\Plugins::getInstance()->execute( \SLiMS\Plugins::CONTENT_BEFORE_LOAD, [$opac] ); // Execute custom API route hook for plugin-defined routes \SLiMS\Plugins::getInstance()->execute('custom_api_route', [ 'router' => $router ]); // Example plugin file structure: plugins/my_plugin/my_plugin.plugin.php $plugin_info = [ 'plugin_name' => 'My Custom Plugin', 'plugin_version' => '1.0.0', 'plugin_author' => 'Developer Name' ]; // Register plugin hook register_plugin_hook('content_before_load', function($opac) { // Modify OPAC behavior $opac->addCustomCSS('plugins/my_plugin/style.css'); }); // Register custom API route in plugin register_plugin_hook('custom_api_route', function($params) { $router = $params['router']; $router->map('GET', '/custom/endpoint', 'CustomController@method'); }); // Configuration for max plugin upload size $sysconf['max_plugin_upload'] = 5000; // in KB ``` -------------------------------- ### Basic Carbon PHP Usage Without Composer Source: https://github.com/slims/slims9_bulian/blob/master/lib/nesbot/carbon/readme.md Illustrates how to use the Carbon package if not using Composer. This involves manually including the Carbon autoloader file after downloading the package release and placing it in your project directory. ```php