PHP code example of cypresslab / gitelephant-bundle
1. Go to this page and download the library: Download cypresslab/gitelephant-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cypresslab / gitelephant-bundle example snippets
php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...other bundles
new Cypress\GitElephantBundle\CypressGitElephantBundle(),
);
// ...other bundles
return $bundles;
}
}
php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...other bundles
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
// ...other development and testing bundles
$bundles[] = new Cypress\GitElephantBundle\CypressGitElephantBundle();
}
return $bundles;
}
}
php
class AwesomeController extends Controller
{
/**
* @Route("/", name="repository_root")
* @Template()
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @return array
*/
public function rootAction(Request $request)
{
// Repository instance
$repositories = $this->get('cypress_git_elephant.repository_collection');
// There is also an handy alias
$repositories = $this->get('git_repositories');
// $repositories is an instance of GitElephant\Cypress\GitElephantBundle\Collection\GitElephantRepositoryCollection
// it has the Countable, ArrayAccess and Iterator interfaces. So you can do:
$num_repos = count($repositories); //number of repositories
$git_elephant = $repositories->get('GitElephant'); // retrieve a Repository instance by its name (defined in config.yml)
// iterate
foreach ($repositories as $repo) {
$repo->getLog();
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.