src/IronWorker.php
public function upload($directory, $run_filename, $code_name, $options = array())
    {
        $temp_file = tempnam(sys_get_temp_dir(), 'iron_worker_php');
        if (array_key_exists('ignored', $options)) {
            if (!is_array($options['ignored'])) {
                $options['ignored'] = [$options['ignored']];
            }
        } else {
            $options['ignored'] = [];
        }
        if (!self::zipDirectory($directory, $temp_file, true, $options['ignored'])) {
            unlink($temp_file);
            return false;
        }
        unset($options['ignored']);
        try {
            $this->postCode($run_filename, $temp_file, $code_name, $options);
        } catch (\Exception $e) {
            unlink($temp_file);
            throw $e;
        }
        return true;
    }
public function upload($directory, $run_filename, $code_name, $options = array())
    {
        $temp_file = tempnam(sys_get_temp_dir(), 'iron_worker_php');
        if (array_key_exists('ignored', $options)) {
            if (!is_array($options['ignored'])) {
                $options['ignored'] = [$options['ignored']];
            }
        } else {
            $options['ignored'] = [];
        }
        if (!self::zipDirectory($directory, $temp_file, true, $options['ignored'])) {
            unlink($temp_file);
            return false;
        }
        unset($options['ignored']);
        try {
            $this->postCode($run_filename, $temp_file, $code_name, $options);
        } catch (\Exception $e) {
            unlink($temp_file);
            throw $e;
        }
        return true;
    }
public function upload ( $ directory , $ run_filename , $ code_name , $ options = array ( ) ) { $ temp_file = tempnam ( sys_get_temp_dir ( ) , 'iron_worker_php' ) ; if ( array_key_exists ( 'ignored' , $ options ) ) { if ( ! is_array ( $ options [ 'ignored' ] ) ) { $ options [ 'ignored' ] = [ $ options [ 'ignored' ] ] ; } } else { $ options [ 'ignored' ] = [ ] ; } if ( ! self :: zipDirectory ( $ directory , $ temp_file , true , $ options [ 'ignored' ] ) ) { unlink ( $ temp_file ) ; return false ; } unset ( $ options [ 'ignored' ] ) ; try { $ this -> postCode ( $ run_filename , $ temp_file , $ code_name , $ options ) ; } catch ( \ Exception $ e ) { unlink ( $ temp_file ) ; throw $ e ; } return true ; }
Zips and uploads your code

Shortcut for zipDirectory() + postCode()

@param string $directory Directory with worker files
@param string $run_filename This file will be launched as worker
@param string $code_name Referenceable (unique) name for your worker
@param array $options Optional parameters:
- "max_concurrency" The maximum number of tasks that should be run in parallel.
- "retries" The number of auto-retries of failed task.
- "retries_delay" Delay in seconds between retries.
- "config" : An arbitrary string (usually YAML or JSON) that, if provided,
will be available in a file that your worker can access.
File location will be passed in via the -config argument.
The config cannot be larger than 64KB in size.
- "ignored" The list of files to be excluded from uploading process.
@return bool Result of operation
@throws \Exception
Zips and uploads your code