PHP code example of alwex / phpdeploy

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

    

alwex / phpdeploy example snippets


class ExampleCommand extends \Deploy\Command\AbstractCommand {

    /**
     * optionally you may check if all the
     * sts("/tmp/hello.txt")) {
            throw new \RuntimeException("hello file already exists");
        }
    }

    /**
     * execute command and php tasks
     * return the execution status as an integer
     *
     * @return void
     */
    public function run()
    {
        $command = "echo hello > /tmp/hello.txt";
        $this->shellExec($command);
    }

    /**
     * optionally you may check if the command has been
     * correctly done
     *
     * @throw \RuntimeException
     */
    public function afterRun() {

        $expectedValue = 'hello';
        $fileContent = file_get_contents("/tmp/hello.txt");

        if ($fileContent != $expectedValue) {
            throw new \RuntimeException("hello file does not contain expected value '$expectedValue', found '$fileContent'");
        }
    }
}