ZenstruckGithubBundle is a project mainly written in PHP, it's free.
Enables a Github repository to become the host of static content for your cms.
Enables a Github repository to become the host of static content for your cms.
Add this bundle and php-github-api to your Symfony2 project:
$ git submodule add git://github.com/kbond/GithubBundle.git vendor/bundles/Zenstruck/GithubBundle
$ git submodule add git://github.com/ornicar/php-github-api.git vendor/php-github-api
Add the Zenstruck
namespace to your autoloader:
// app/autoload.php
$loader->registerNamespaces(array(
'Zenstruck' => __DIR__.'/../vendor/bundles',
// your other namespaces
));
Add the Github
prefix to your autoloader:
// app/autoload.php
$loader->registerPrefixes(array(
'Github_' => __DIR__.'/../vendor/php-github-api/lib'
// your other prefixes
));
Add this bundle to your application's kernel:
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Zenstruck\Bundle\GithubBundle\ZenstruckGithubBundle(),
// ...
);
}
# app/config/config.yml
zenstruck_github:
user: # the github username
repo: # the github reponame
branch: master # git branch
// get service
$repo = $this->get('zenstruck.github.filesystem');
// get file from repo (extension required)
$index = $repo->getFile('index.md');
$contents = $index->getContent();
// get a file from (extension not required)
$index = $repo->getMatchingFile('index');
$contents = $index->getContent();
// get file list
$files = $repo->getFileList();
// get file list in subdir
$files = $repo->getFileList('subdir');