lib/Github/Api/Repository/Contents.php
public function create($username, $repository, $path, $content, $message, $branch = null, array $committer = null)
    {
        $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents/'.rawurlencode($path);

        $parameters = [
          'content' => base64_encode($content),
          'message' => $message,
        ];

        if (null !== $branch) {
            $parameters['branch'] = $branch;
        }

        if (null !== $committer) {
            if (!isset($committer['name'], $committer['email'])) {
                throw new MissingArgumentException(['name', 'email']);
            }
            $parameters['committer'] = $committer;
        }

        return $this->put($url, $parameters);
    }
public function create($username, $repository, $path, $content, $message, $branch = null, array $committer = null)
    {
        $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents/'.rawurlencode($path);

        $parameters = [
          'content' => base64_encode($content),
          'message' => $message,
        ];

        if (null !== $branch) {
            $parameters['branch'] = $branch;
        }

        if (null !== $committer) {
            if (!isset($committer['name'], $committer['email'])) {
                throw new MissingArgumentException(['name', 'email']);
            }
            $parameters['committer'] = $committer;
        }

        return $this->put($url, $parameters);
    }
public function create ( $ username , $ repository , $ path , $ content , $ message , $ branch = null , array $ committer = null ) { $ url = '/repos/' . rawurlencode ( $ username ) . '/' . rawurlencode ( $ repository ) . '/contents/' . rawurlencode ( $ path ) ; $ parameters = [ 'content' => base64_encode ( $ content ) , 'message' => $ message , ] ; if ( null !== $ branch ) { $ parameters [ 'branch' ] = $ branch ; } if ( null !== $ committer ) { if ( ! isset ( $ committer [ 'name' ] , $ committer [ 'email' ] ) ) { throw new MissingArgumentException ( [ 'name' , 'email' ] ) ; } $ parameters [ 'committer' ] = $ committer ; } return $ this -> put ( $ url , $ parameters ) ; }
Creates a new file in a repository.

@link http://developer.github.com/v3/repos/contents/#create-a-file

@param string      $username   the user who owns the repository
@param string      $repository the name of the repository
@param string      $path       path to file
@param string      $content    contents of the new file
@param string      $message    the commit message
@param null|string $branch     name of a branch
@param null|array  $committer  information about the committer

@throws MissingArgumentException

@return array information about the new file
Creates a new file in a repository .