PHP code example of shaggy8871 / yami

1. Go to this page and download the library: Download shaggy8871/yami 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/ */

    

shaggy8871 / yami example snippets




return [
    'environments' => [
        'default' => [
            'yaml' => [
                'adapter' => 'file',
                'file' => 'default.yaml',
            ],
            'migrations' => [
                'path' => './migrations',
            ],
        ],
    ],
    'save' => [
        'indentation' => 2,
    ]
];



use Yami\Migration\AbstractMigration;

class TestMigration extends AbstractMigration
{

    public function up()
    {
        $node = $this->get('.');
        $node->add(['foo' => 'bar']);

        $this->save();
    }

    public function down()
    {
        $node = $this->get('.');
        $node->remove('foo');

        $this->save();
    }

}

$node = $this->get('.');
$node->add(['foo' => 'bar']);

$node = $this->get('.foo.bar');
$node->add(['new' => 'value']);



return [
    'environments' => [
        /**
         * The development.yaml file may be committed if it's masked
         */
        'development' => [
            'yaml' => [
                'adapter' => 'file',
                'file' => 'development.yaml',
            ],
            'migrations' => [
                'path' => './migrations',
            ],
            'save' => [
                'maskValues' => true,
                'indentation' => 4,
            ]
        ],
        /**
         * The production.yaml file is not masked, so should not be committed
         */
        'production' => [
            'yaml' => [
                'adapter' => 'file',
                'file' => 'production.yaml',
            ],
            'migrations' => [
                'path' => './migrations',
            ],
        ]
    ],
    'save' => [
        'indentation' => 2,
    ]
];



return [
    'environments' => [
        'default' => [
            'yaml' => [
                'adapter' => 'file',
                'file' => 'default.yaml',
            ],
            'migrations' => [
                'path' => './migrations',
            ],
            'secretsManager' => [
                'adapter' => 'ssm',
                'credentials' => [
                    'profile' => 'default',
                    'region' => 'us-east-1'
                ]
            ]
        ]
    ]
];



use Yami\Migration\AbstractMigration;

class TestClass extends AbstractMigration
{
    public function up()
    {
        $node = $this->get('.');
        $node->add([
            'foo' => 'bar',
            'access_key_id' => $this->secret('/api/production/s3/access_key_id', [
                'type' => 'string'
            ]),
            'secret_access_key' => $this->secret('/api/production/s3/secret_access_key', [
                'type' => 'string'
            ])
        ]);

        $this->save();
    }
}