PHP code example of mouf / utils.patcher

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

    

mouf / utils.patcher example snippets


// The class will be generated by the patch system
class MyPatch extends AbstractSchemaMigrationPatch
{
    public function up(Schema $schema) : void
    {
        // Use the "up" function to alter the database model.
        // The $schema object documentation can be found in Doctrine DBAL documentation:
        //   http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/schema-representation.html
        
        // For instance:
        $table = $schema->createTable('posts');
        $table->addColumn('id', 'integer');
        $table->addColumn('description', 'string');
        $table->setPrimaryKey(['id']);
    }
    
    public function down(Schema $schema) : void
    {
        // Code your migration cancellation code here.
    }
    
    public function getDescription(): string
    {
        return 'The comment for your patch (displayed in the Mouf patch list or in the CLI command)';
    }
}

// The class will be generated by the patch system
class MyPatch extends AbstractDataMigrationPatch
{
    public function up(Connection $connection) : void
    {
        // Use the "up" function to alter the data.
        // The $connection object documentation can be found in Doctrine DBAL documentation:
        //   http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/data-retrieval-and-manipulation.html
        
        // For instance:
        $connection->insert('posts', [
            'id' => 1,
            'description' => 'foobar'
        ]);
    }
    
    public function down(Connection $connection) : void
    {
        // Code your migration cancellation code here.
    }
    
    public function getDescription(): string
    {
        return 'The comment for your patch (displayed in the Mouf patch list or in the CLI command)';
    }
}