Comments (3)
Ok link to previous one #78
The quickest solution i found was to use
$client = resolve('github.connection');//to get the services provided by the provider
and then use on it the paginator of native lib KnpLabs/php-github-api
$repoApi = $client->api('repo');
$paginator = new \Github\ResultPager($client );
$parameters = array($org_name, ['page' => 1, 'per_page' => 100]);
$repos_array = $paginator->fetch($repoApi, $method, $parameters);
from laravel-github.
Thanks for getting in touch. Yeh, you'll need to use the paginator. You don't need to pass the extra page info however, and the fetchAll
method is probably the one you're after here. The repo api is not what you want though - that will end up listing everything on all of GitHub. I stead, you'll want the organization API:
The following will suffice (using dependency injection to get the client instance - equivalent to manual resolution of the alias like you did):
<?php
use Github\Client;
use Github\ResultPager;
class Example
{
function getRepos(Client $client)
{
$pager = new ResultPager($client);
return $pager->fetchAll(
$client->organization(),
'repositories',
['some_org_name']
);
}
}
app()->call('Example@getRepos');
If you're ever in doubt of what stuff is available, take a gander at https://github.com/KnpLabs/php-github-api/tree/master/lib/Github/Api. That's essentially what I pulled up to write this example for you. :)
from laravel-github.
Thank you for advises. I was looking for a clean way to still use dependency injection with some other arguments in my method which is called by a job.
Based on your solution i slightly modified it and put it in case someone has same question as me.
Hopefully it is not dirty.
<?php
namespace App\Service;
use Github\Client;
use Github\ResultPager;
class Example
{
function getRepos(Client $client, $argument)
{
$pager = new ResultPager($client);
//argument for example for in place of 'some_org_name'
return $pager->fetchAll(
$client->organization(),
'repositories',
['some_org_name']
);
}
}
$example = App::make('App\Service\Example');
App::call([$example ,'getRepos'],['argument'=>$someArgument]);
from laravel-github.
Related Issues (20)
- Private Repos HOT 5
- Error authenticating as GitHub application - 'Expiration time' claim ('exp') is too far in the future HOT 9
- Behavior change in version 4.0 of `lcobucci/jwt` causing `private` authentication failure. HOT 3
- Dynamic Connections? HOT 1
- Fork needed
- SEGDEF Issue
- 'Expiration time' claim ('exp') must be a numeric value representing the future time at which the assertion expires HOT 14
- guzzlehttp/guzzle:^7.2 install issue with this HOT 7
- How to switch connection at runtime and assign a new connection when the rate limit has been exceeded. HOT 1
- Composer error HOT 4
- Facades doen't get Docblocks for ide-helper HOT 1
- Projects V2 API HOT 1
- Support github-api 3.9.* HOT 2
- Laravel 10 Update HOT 2
- Method 'repo' not found in \GrahamCampbell\GitHub\Facades\GitHub HOT 3
- Support for symfony/cache:^7.0 HOT 1
- `Package php-http/message-factory is abandoned, you should avoid using it. Use psr/http-factory instead` message on installation HOT 4
- Support Laravel 11 HOT 1
- PHPStan error: Call to an undefined static method HOT 1
- [QUESTION] How to use with GitHub Apps?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-github.