PHP code example of directorytree / opensearch-migrations
1. Go to this page and download the library: Download directorytree/opensearch-migrations library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
directorytree / opensearch-migrations example snippets
use DirectoryTree\OpenSearchAdapter\Indices\Mapping;
use DirectoryTree\OpenSearchAdapter\Indices\Settings;
use DirectoryTree\OpenSearchMigrations\Facades\Index;
use DirectoryTree\OpenSearchMigrations\MigrationInterface;
class CreatePostsIndex implements MigrationInterface
{
public function up(): void
{
Index::create('posts', function (Mapping $mapping, Settings $settings) {
$mapping->text('title');
$mapping->text('body');
});
}
public function down(): void
{
Index::dropIfExists('posts');
}
}