Github api 和 PHP

Github api with PHP

我是 php 的新手,我正在尝试制作一个脚本,该脚本将在 github 中创建一个新的存储库,并捕获我电脑中的文档并在此新存储库中进行提交.该脚本将在 cmd 中执行。我搜索 github api 并下载了包含多个文件的任何文件夹,我使用作曲家安装了一些东西,但我无法在我的 [=60= 中创建 github 的新实例].

我对此一无所知,我在这方面花了两天时间,但我无法编写与 github 对话的函数。在 github 开发人员的网站上我什么都不懂,我真的需要这样做,我很迷茫。我正在使用 PhpStorm 6.0.3。

我不明白的是:

1- api 是一个包含很多文件的文件夹?或者是在php风暴中导入的库?我如何将它放在 phpstorm 中,因为我可以获得方法并创建我的函数?

2- 我从哪里得到与 github api 交谈的方法?我在哪里可以看到它们?在 github 开发人员中我什么都不懂。

我看到一个类似的问题,但对我帮助不大。 请帮助我

编辑

我下载了一个 api,我使用了 composer require,显然一切都很好,但是当我执行一些文件来测试 api 时,同样的错误弹出。该程序无法在同一文件夹中找到项目中的某些文件。 例如:PHP 致命错误:第 15 行

中的 D:\php-github-api-master\lib\Github\Api\AbstractApi.php 中未找到接口 'Github\Api\ApiInterface'

在其他文件中出现相同的错误,我将 "use" 引用我尝试使用但不起作用的文件。例如:使用 Github\Api\ApiInterface;

编辑

此代码将创建一个新的存储库,对吗?当我执行这段代码时,我得到上面的错误,Class 'Github\Api\AbstractApi' not found,但是 class 在那里。

class Repo 扩展了 AbstractApi { public 函数创建( $名字, $描述 = '', $主页 = '', $public = 真, $组织=空, $hasIssues = 错误, $hasWiki = false, $hasDownloads = 假, $teamId = null, $autoInit = 假 ) { $path = null !== $organization ? 'orgs/'.$organization.'/repos' : 'user/repos';</p> <pre> $parameters = array( 'name' => $name, 'description' => $description, 'homepage' => $homepage, 'private' => !$public, 'has_issues' => $hasIssues, 'has_wiki' => $hasWiki, 'has_downloads' => $hasDownloads, 'auto_init' => $autoInit ); if ($organization && $teamId) { $parameters['team_id'] = $teamId; } return $this->post($path, $parameters); }

}

谢谢,

约翰。

我完成了我的脚本,一切都正确完成了,对于我明显的问题感到抱歉,并感谢谁回答了我。我的代码:

<?php

include "vendor/autoload.php";

$client = new \Github\Client();
$username = "JohannLucas";
$password = "mypassword";

$method = Github\Client::AUTH_HTTP_PASSWORD;
//authenticate
$client->authenticate($username, $password, $method);

//Apagar Repositório
//$client->api('repo')->remove('JohannLucas', 'teste');

//Criar Repositório
$client->api('repo')->create('olamundo', 'Repositorio criado com o github api', 'http://my-repo-homepage.org', true);

//Commit

$committer = array('name' => 'JohannLucas', 'email' => 'johann.lucas@hotmail.com');
$path = "teste.txt";
$commitMessage = "Commit do teste.txt";

$content = "Olá Mundo!";
$branch = "master";
$repo = "olamundo";

$fileInfo = $client->api('repo')->contents()->create('JohannLucas', 'olamundo', $path, $content, $commitMessage, $branch, $committer);

print_r("Foi!");

谢谢!

约翰