PHP code example of iseed838 / githooks

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

    

iseed838 / githooks example snippets


    'githook.yii.parameters' => function () {
        return GitHooksParameters::make();
    },

    'githook.post_merge.migrate' => function () {
        return new GitHookRule(GitHooksParameters::HOOK_POST_MERGE, AlwaysEvent::make(),
    MigrateEventHandler::make(), Yii::$container->get('githook.yii.parameters'));
    },
    'githook.post_merge.cache_flush' => function () {
        return new GitHookRule(GitHooksParameters::HOOK_POST_MERGE, AlwaysEvent::make(),
    CacheFlushEventHandler::make(), Yii::$container->get('githook.yii.parameters'));
    },

        'githook.yii.parameters'              => function () {
            return GitHooksParameters::make();
        },
        'githook.yii_test.parameters'         => function () {
            $parameters = GitHooksParameters::make();
        
            return $parameters->setYiiPath('yii_test');
        },
        'githook.post_merge.migrate'          => function () {
            return new GitHookRule(GitHooksParameters::HOOK_POST_MERGE, AlwaysEvent::make(),
                MigrateEventHandler::make(), Yii::$container->get('githook.yii.parameters'));
        },
        'githook.post_merge.cache_flush'      => function () {
            return new GitHookRule(GitHooksParameters::HOOK_POST_MERGE, AlwaysEvent::make(),
                CacheFlushEventHandler::make(), Yii::$container->get('githook.yii.parameters'));
        },
        'githook.post_merge.lang_drop'        => function () {
            return new GitHookRule(GitHooksParameters::HOOK_POST_MERGE, AlwaysEvent::make(),
                RedisDropEventHandler::make(), Yii::$container->get('githook.yii.parameters'));
        },
        'githook.post_merge.composer_install' => function () {
            return new GitHookRule(GitHooksParameters::HOOK_POST_MERGE, ComposerChangeEvent::make(),
                ComposerUpdateEventHandler::make(), Yii::$container->get('githook.yii.parameters'));
        },
        'githook.post_merge.npm_install'      => function () {
            return new GitHookRule(GitHooksParameters::HOOK_POST_MERGE, NodeChangeEvent::make(),
                NodeUpdateEventHandler::make(), Yii::$container->get('githook.yii.parameters'));
        },
        'githook.post_merge.test_migrate'     => function () {
            return new GitHookRule(GitHooksParameters::HOOK_POST_MERGE, AlwaysEvent::make(),
                MigrateEventHandler::make(), Yii::$container->get('githook.yii_test.parameters'));
        },
        'githook.post_merge.test_cache_flush' => function () {
            return new GitHookRule(GitHooksParameters::HOOK_POST_MERGE, AlwaysEvent::make(),
                CacheFlushEventHandler::make(), Yii::$container->get('githook.yii_test.parameters'));
        },
        GitHooksParameters::class             => [
            'rules' => [
                Instance::of('githook.post_merge.migrate'),
                Instance::of('githook.post_merge.cache_flush'),
                Instance::of('githook.post_merge.lang_drop'),
                Instance::of('githook.post_merge.composer_install'),
                Instance::of('githook.post_merge.npm_install'),
                Instance::of('githook.post_merge.test_migrate'),
                Instance::of('githook.post_merge.test_cache_flush'),
            ]
        ]