Git Product home page Git Product logo

zenstruckgithubbundle's Introduction

Introduction

Enables a Github repository to become the host of static content for your cms.

Requirements

Installation

  1. 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
    
  2. Add the Zenstruck namespace to your autoloader:

     // app/autoload.php
     $loader->registerNamespaces(array(
        'Zenstruck' => __DIR__.'/../vendor/bundles',
        // your other namespaces
     ));
    
  3. Add the Github prefix to your autoloader:

     // app/autoload.php
     $loader->registerPrefixes(array(
         'Github_'            => __DIR__.'/../vendor/php-github-api/lib'
         // your other prefixes
     ));
    
  4. Add this bundle to your application's kernel:

     // app/AppKernel.php
      public function registerBundles()
      {
          return array(
              // ...
              new Zenstruck\Bundle\GithubBundle\ZenstruckGithubBundle(),
              // ...
          );
      }
    

Configuration

# app/config/config.yml
zenstruck_github:
    user: # the github username
    repo: # the github reponame
    branch: master # git branch

Usage

// 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');

Todo

  • Controller to publish content file based on a github path
  • Allow deeper levels (need slashes in route params - not sure how to do this)
  • Cache?

zenstruckgithubbundle's People

Contributors

kbond avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.