Coder Social home page Coder Social logo

laravel-github's Introduction

Laravel GitHub

Laravel GitHub was created by, and is maintained by Graham Campbell, and is a PHP GitHub API bridge for Laravel. It utilises my Laravel Manager package. Feel free to check out the change log, releases, security policy, license, code of conduct, and contribution guidelines.

Banner

Build Status StyleCI Status Software License Packagist Downloads Latest Version

Installation

This version requires PHP 7.4-8.3 and supports Laravel 8-11.

GitHub L5.5 L5.6 L5.7 L5.8 L6 L7 L8 L9 L10 L11
7.8
8.9
9.8
10.6
11.0
12.6

To get the latest version, simply require the project using Composer:

$ composer require "graham-campbell/github:^12.6"

Once installed, if you are not using automatic package discovery, then you need to register the GrahamCampbell\GitHub\GitHubServiceProvider service provider in your config/app.php.

You can also optionally alias our facade:

        'GitHub' => GrahamCampbell\GitHub\Facades\GitHub::class,

Configuration

Laravel GitHub requires connection configuration.

To get started, you'll need to publish all vendor assets:

$ php artisan vendor:publish

This will create a config/github.php file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.

There are two config options:

Default Connection Name

This option ('default') is where you may specify which of the connections below you wish to use as your default connection for all work. Of course, you may use many connections at once using the manager class. The default value for this setting is 'main'.

GitHub Connections

This option ('connections') is where each of the connections are setup for your application. Example configuration has been included, but you may add as many connections as you would like. Note that the 5 supported authentication methods are: "application", "jwt", "none", "private", and "token".

HTTP Cache

This option ('cache') is where each of the cache configurations setup for your application. Only the "illuminate" driver is provided out of the box. Example configuration has been included.

Usage

GitHubManager

This is the class of most interest. It is bound to the ioc container as 'github' and can be accessed using the Facades\GitHub facade. This class implements the ManagerInterface by extending AbstractManager. The interface and abstract class are both part of my Laravel Manager package, so you may want to go and checkout the docs for how to use the manager class over at that repo. Note that the connection class returned will always be an instance of Github\Client.

Facades\GitHub

This facade will dynamically pass static method calls to the 'github' object in the ioc container which by default is the GitHubManager class.

GitHubServiceProvider

This class contains no public methods of interest. This class should be added to the providers array in config/app.php. This class will setup ioc bindings.

Real Examples

Here you can see an example of just how simple this package is to use. Out of the box, the default adapter is main. After you enter your authentication details in the config file, it will just work:

use GrahamCampbell\GitHub\Facades\GitHub;
// you can alias this in config/app.php if you like

GitHub::me()->organizations();
// we're done here - how easy was that, it just works!

GitHub::repo()->show('GrahamCampbell', 'Laravel-GitHub');
// this example is simple, and there are far more methods available

The github manager will behave like it is a Github\Client class. If you want to call specific connections, you can do with the connection method:

use GrahamCampbell\GitHub\Facades\GitHub;

// the alternative connection is the other example provided in the default config
GitHub::connection('alternative')->me()->emails()->add('[email protected]');

// now we can see the new email address in the list of all the user's emails
GitHub::connection('alternative')->me()->emails()->all();

With that in mind, note that:

use GrahamCampbell\GitHub\Facades\GitHub;

// writing this:
GitHub::connection('main')->issues()->show('GrahamCampbell', 'Laravel-GitHub', 2);

// is identical to writing this:
GitHub::issues()->show('GrahamCampbell', 'Laravel-GitHub', 2);

// and is also identical to writing this:
GitHub::connection()->issues()->show('GrahamCampbell', 'Laravel-GitHub', 2);

// this is because the main connection is configured to be the default
GitHub::getDefaultConnection(); // this will return main

// we can change the default connection
GitHub::setDefaultConnection('alternative'); // the default is now alternative

If you prefer to use dependency injection over facades like me, then you can easily inject the manager like so:

use GrahamCampbell\GitHub\GitHubManager;

class Foo
{
    private GitHubManager $github;

    public function __construct(GitHubManager $github)
    {
        $this->github = $github;
    }

    public function bar()
    {
        $this->github->issues()->show('GrahamCampbell', 'Laravel-GitHub', 2);
    }
}

app(Foo::class)->bar();

For more information on how to use the Github\Client class we are calling behind the scenes here, check out the docs at https://github.com/KnpLabs/php-github-api/tree/v3.14.0/doc, and the manager class at https://github.com/GrahamCampbell/Laravel-Manager#usage.

Further Information

There are other classes in this package that are not documented here. This is because they are not intended for public use and are used internally by this package.

Security

If you discover a security vulnerability within this package, please send an email to [email protected]. All security vulnerabilities will be promptly addressed. You may view our full security policy here.

License

Laravel GitHub is licensed under The MIT License (MIT).

For Enterprise

Available as part of the Tidelift Subscription

The maintainers of graham-campbell/github and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

laravel-github's People

Contributors

ahinkle avatar darkboywonder avatar diegohq avatar driesvints avatar dschniepp avatar ellisio avatar grahamcampbell avatar jbrooksuk avatar jrean avatar lucasmichot avatar phated avatar polakosz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-github's Issues

Cannot set Page or PerPage in api call

Hello,
Seems to be related to php-github-api library.
Some methods cannot be used with page or perpage parameters (using an array)
As:
repo()->contributors(), user()->repositories, repo()->activity() or repo()->frequency()
etc...
So we cannot fetch other result pages provided by Github

token coming from socialite

Hi Graham, I would like to use your api to manage repos but have the users tokens coming from socialite used instead of configured connections. Does the manager have the ability to do this or is this outside this scope of this product?

Thanks,
Nigel

repository lists incomplete

Hi, quick question. When I call for a list of repos for a user the list returned is incomplete seems to cut off at 20 total.

GitHub::api('user')->repositories($username);

Is there anyway I can get it to return the entire list? thanks

Issue using this package with an application phar

Hey there. Thanks for this package (and all your others)! Definitely has made my life easier interacting with github.

I'm working on a new project at the moment with Laravel-Zero, and am running into a problem when the application is built into a phar.

In the GithubServiceProvider, while attempting to merge the config files, there's a call to realpath() which it appears does not play nice, on purpose, with phars. Here's what I'm seeing:

Line in question is 47:
$source = realpath(__DIR__.'/../config/github.php');

Since the path starts with phar://, realpath treats this as an error and returns false. Then when it tries to require that file, I get this error:

PHP Warning:  require(): Filename cannot be empty in phar:///path/to/project/builds/application.phar/vendor/illuminate/support/ServiceProvider.php on line 62

And the top of the stacktrace:

#0  Illuminate\Support\ServiceProvider->mergeConfigFrom(, github) called at [phar:///path/to/project/builds/application.phar/vendor/graham-campbell/github/src/GitHubServiceProvider.php:59]
#1  GrahamCampbell\GitHub\GitHubServiceProvider->setupConfig() called at [phar:///path/to/project/builds/application.phar/vendor/graham-campbell/github/src/GitHubServiceProvider.php:37]

I tested by removing the call to realpath, and the source variable became phar:///path/to/project/builds/application.phar/vendor/graham-campbell/github/src/../config/github.php. With this change, the config file is required just fine.

I'm not sure that just simply removing the call to realpath is the real solution here, perhaps a check if it's false after the call, but I wanted to see if you have run into this before, and what you think about it?

Thanks!
-Adam

Can't figure this out

Hi,

I have downloaded this, but have no idea where to start for writing my calls to the API.

I know it uses knplabs/php-github-api but it seems to change everything from there.

Any help?

Guzzle6 FatalThrowableError

Installed as mentioned in readme. But it shows the following error:
Using default main token method.

Symfony\Component\Debug\Exception\FatalThrowableError: Too few arguments to function Http\Adapter\Guzzle6\Client::buildClient(), 0 passed in \vendor\php-http\guzzle6-adapter\src\Client.php on line 31 and exactly 1 expected in file \vendor\php-http\guzzle6-adapter\src\Client.php on line 76
Stack trace:
  1. Symfony\Component\Debug\Exception\FatalThrowableError->() \vendor\php-http\guzzle6-adapter\src\Client.php:76
  2. Http\Adapter\Guzzle6\Client->buildClient() \vendor\php-http\guzzle6-adapter\src\Client.php:31
  3. Http\Adapter\Guzzle6\Client->__construct() \vendor\php-http\discovery\src\ClassDiscovery.php:203
  4. Http\Discovery\ClassDiscovery->instantiateClass() \vendor\php-http\discovery\src\HttpClientDiscovery.php:34
  5. Http\Discovery\HttpClientDiscovery->find() \vendor\knplabs\github-api\lib\Github\HttpClient\Builder.php:85
  6. Github\HttpClient\Builder->__construct() \vendor\graham-campbell\github\src\GitHubFactory.php:92
  7. GrahamCampbell\GitHub\GitHubFactory->getBuilder() \vendor\graham-campbell\github\src\GitHubFactory.php:70

[Lumen] undefined function `config_path()'

$ php artisan serve
PHP Fatal error:  Call to undefined function GrahamCampbell\GitHub\config_path() in /path/to/project/vendor/graham-campbell/github/src/GitHubServiceProvider.php on line 43

If I comment out the 43. line at ./vendor/graham-campbell/github/src/GitHubServiceProvider.php:43 my project, everything works as should.

I saw that @GrahamCampbell has already dealt with this issue here.


     protected function setupConfig()
     {
         $source = realpath(__DIR__.'/../config/github.php');

-        $this->publishes([$source => config_path('github.php')]);
+        // $this->publishes([$source => config_path('github.php')]);

         $this->mergeConfigFrom($source, 'github');
     }

Token?

The config file says your-token but what token is that exactly? Login token?

How to Get Private Repo Info

I struggled with this for a few hours since it seemed that a lot of the documentation wasn't that thorough or you had to piece it together... but basically, if you want to use this package to get private repos... here's what I did.

Step 1:
Log in to your github and add a personal access token. Be sure to copy it after it is created.

Step 2:
Configure the alternative (or whichever you'd like) connection with the access token, replacing "your-token" with the copied token from step 1.

Step 3:
$repo = GitHub::connection('alternative')->repo()->show('myusername', 'myprivaterepo');

And done!
Thanks @GrahamCampbell for your work with this package!

laravel Socialite error

here my controller


use Illuminate\Http\Request;
use GitHub;
use Socialite;
use GrahamCampbell\GitHub\Authenticators\AuthenticatorFactory;
use GrahamCampbell\GitHub\GitHubFactory;
class HomeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
        return Socialite::driver('github')->redirect();
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }
    public function callback(){
        $user = Socialite::driver('github')->user();
        echo $user->token;
        // $issues = $client->api('issue')->all('KnpLabs', 'php-github-api', array('state' => 'open'));
        app(GitHubFactory::class)->make(['token' => $user->token, 'method' => 'token']);
        $issues = GitHub::connection()->issues()->show('tes', 'tes', 2);
        echo "<pre>";
        print_r($issues);
    }

but when I running this code I get error like this
http://imgur.com/2Hh86tR

Issues inviting new collaborator to organisation

Hello to you, thanks for making this awsome package ! I just have one small issue using it, I am trying to invite news collaborators to my organisation but I get error not found I have posted on stackoverflow I was wondering if this was maybe a known issue. Thanks ahead.

Enterprise connection returning 404 not found

Controller code

public function show() {
  // works
  return $this->github->connection('alternative')->me()->show();
}

public function show() {
  // works
  return shell_exec('curl https://github.example.com/api/v3/user?access_token=my-valid-enterprise-token');
}

public function show() {
  // fails :(
  return $this->github->connection('main')->me()->show();
}

github.config

'connections' => [
  'main' => [
    'token'      => 'my-valid-enterprise-token',
    'method'     => 'token',
    'version'    => 'v3',
    'enterprise' => 'https://github.example.com/',
  ],
  'alternative' => [
    'token'      => 'my-valid-github-token',
    'method'     => 'token',
  ],
]

How to use app authentication?

Hi and thanks for the great package.

I am struggling to make app connection work. Is there any example?

I've configured this replacing with me app credentials

'app' => [
            'clientId'     => 'your-client-id',
            'clientSecret' => 'your-client-secret',
            'method'       => 'application',
],

But if I try to access private endpoints like $github->me()->repositories() I get

Github \ Exception \ RuntimeException (401)
Requires authentication

I guess with this auth method it will have to redirect you to Github OAuth page first, but I think this library does not handle that out of the box? In other words by using app auth, the user have to already granted permissions to the app?

Can you advise how to approach this in order to make it work or if I am missing something?

It would be nice to have this handled in the library itself, e.g. to generate OAuth url that I can redirect the user to, and also hooks to capture the auth action when it occurs.

php artisan vendor:publish laravel 5.4 not copying

On a fresh install of Laravel 5.4 following the instructions in your README the config file (and source but not sure if that is meant to copy) isn't being copied as expected.

Running php artisan vendor:publish returns the following:

Copied Directory [\vendor\laravel\framework\src\Illuminate\Notifications\resources\views] To [\resources\views\vendor\notifications]
Copied Directory [\vendor\laravel\framework\src\Illuminate\Pagination\resources\views] To [\resources\views\vendor\pagination]
Copied Directory [\vendor\laravel\framework\src\Illuminate\Mail\resources\views] To [\resources\views\vendor\mail]
Publishing complete.

Clean way to use KnpLabs Result Pager with Laravel

I might be wrong but there is a facade for Github\Client , do you plan to add something similar for using the paginator? seems not clean to call the native class after using your package for client

Getting token from db?

I have the github token in my db. It can be accessed using

use Auth;
$user = Auth::user();
$token = $user->token;

As (I think) you can't use some functions in config files, how can I archieve that?

Package suggests updates

guzzle/guzzle suggests installing guzzlehttp/guzzle (Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated.)

knplabs/github-api suggests installing knplabs/gaufrette (Needed for optional Gaufrette cache)

paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)

Would these be able to be updated?

Laravel 5.8 Version

Hi,

First thanks for this package. I have seen there are changes to support Laravel 5.8 in master branch but no version has been released with these changes. I'd hope to see a release soon as this is the only package blocking the Laravel upgrade in one of our projects.

Thanks in advance

Package guzzle/guzzle is abandoned

When installing this package this warning appears:

Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.

Error on Laravel 5.5 install

The error:

  Problem 1
    - knplabs/github-api 2.6.x-dev requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.5.0 requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.4.0 requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.3.0 requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.2.0 requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.1.0 requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.0.1 requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.0.0-rc4 requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.0.0-rc3 requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.0.0-rc2 requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.0.0-rc1 requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.0.0-rc requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.0.0 requires php-http/client-implementation ^1.0 -> no matching package found.
    - graham-campbell/github v5.1.0 requires knplabs/github-api ^2.0 -> satisfiable by knplabs/github-api[2.0.0, 2.0.0-rc, 2.0.0-rc1, 2.0.0-rc2, 2.0.0-rc3, 2.0.0-rc4, 2.0.1, 2.1.0, 2.2.0, 2.3.0, 2.4.0, 2.5.0, 2.6.x-dev].
    - Installation request for graham-campbell/github ^5.1 -> satisfiable by graham-campbell/github[v5.1.0].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Relevant composer:

{
    "license": "proprietary",
    "authors": [
        {
            "name": "Josh Bruce",
            "email": "[email protected]"
        }
    ],
    "require": {
        "php": ">=7.0.0",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "^1.0",
        "doctrine/dbal": "^2.5",
        "watson/active": "2.0.*",
        "graham-campbell/markdown": "^7.1",
        "graham-campbell/github": "^5.1",
        "webuni/commonmark-table-extension": "^0.7.0",
        "stripe/stripe-php": "^5.1",
        "hashids/hashids": "^2.0",
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~5.7",
        "symfony/css-selector": "3.1.*",
        "symfony/dom-crawler": "3.1.*"
    },
    "minimum-stability": "dev",
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/",
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize",
            "npm install"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize",
            "npm update"
        ]
    }
}

Not sure if changing the minimum stability would do anything. Oddly enough - I don't tink I had the problem prior to upgrading Laravel to 5.5.

how can I download blob files which are bigger than 1MB

I've tried this,
$fileContent = GitHub::repo('git-data')->contents()->download($this->owner, $this->repo, $path, $ref);
I tried it by git and gitData also but every time I got this error. I also tried show() method with no progress.

This API returns blobs up to 1 MB in size. The requested blob is too large to fetch via the API, but you can use the Git Data API to request blobs up to 100 MB in size

Needs some authentication documentation

This looks like a great lib, but it needs some more documentation (specifically on how to authenticate your requests or use with OAuth). Linking to KnpLabs/php-github-api is not sufficient.

Mocking member functions

Hi!
Maybe this doesnt belong here, but I'm very lost...
I'm in Laravel 5.4, writing tests for my application, and I want to mock

Github::api('organization')->members()->add($org->name, $this->argument('username'));

I've tried with

Github::shouldReceive('api')
                  ->once()
                  ->andReturn(null);

but it throws this error:

1) Tests\Unit\JoinTest::testAuth
Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function members() on null

How can I do it?

Accessing token from DB

Greetings, I'm kinda new to the whole Laravel community, so please pardon if this is not the place to post this. I'm using OAuth2 to get my github token and I'm saving it in the users table. Using your class what would be the best way to access that token to make the API calls?

Unable to install on Laravel 5.7

Installing on clean install of Laravel 5.7

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install graham-campbell/github v7.5.0
    - Installation request for graham-campbell/github ^7.5 -> satisfiable by graham-campbell/github[7.5.x-dev, v7.5.0].
    - graham-campbell/github 7.5.x-dev requires knplabs/github-api 2.7.*|2.8.*|2.9.*|2.10.* -> satisfiable by knplabs/github-api[2.10.0, 2.10.1, 2.7.0, 2.8.0, 2.9.0].
    - knplabs/github-api 2.10.0 requires php-http/httplug ^1.1 -> satisfiable by php-http/httplug[v1.1.0].
    - knplabs/github-api 2.10.1 requires php-http/httplug ^1.1 -> satisfiable by php-http/httplug[v1.1.0].
    - knplabs/github-api 2.7.0 requires php-http/httplug ^1.1 -> satisfiable by php-http/httplug[v1.1.0].
    - knplabs/github-api 2.8.0 requires php-http/httplug ^1.1 -> satisfiable by php-http/httplug[v1.1.0].
    - knplabs/github-api 2.9.0 requires php-http/httplug ^1.1 -> satisfiable by php-http/httplug[v1.1.0].
    - Conclusion: don't install php-http/httplug v1.1.0

Any help appreciated

Related: #65, #71

Cache?

How do we configure and use cache?
Thank you!

Getting 'Bad Credentials' when trying to use this

Hi @GrahamCampbell,

Just installed this with composer on laravel 4 and setup the config like so:

'default' => 'main',

    /*
    |--------------------------------------------------------------------------
    | GitHub Connections
    |--------------------------------------------------------------------------
    |
    | Here are each of the connections setup for your application. Example
    | configuration has been included, but you may add as many connections as
    | you would like.
    |
    */

    'connections' => [
        'main' => [
            'token'   => ' d3a0ec2f14a77bcfc39699ed8c3546714b6782a5',
        ],
    ],

I set all this up in the github settings for applications and created an app and auth token:

screen shot 2015-03-03 at 20 29 54

GitHub::me()->organizations();

When I try to access some data I get this:

'Bad credentials'

What could it be?

Setting private access token

Hi there!

I'm trying to set a private access token I acquired beforehands to request private repositories.

Github::authenticate(Auth::user()->github_token, null, 'http_token');

But somehow, I am doing something wrong, because

var_dump(Github::api('user')->repositories($username));

only shows public repositories. Am I missing something?

about a warning i got from composer

Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
could i just fork the project , work with guzzlehttp and apply fixes wherever the calling method differs and do a pull request !?
i am not an average contibutor to projects on github but am trying to be ! i'll use this package to make a cool project for searching repositories on github 👯

Service

Hi,

Since latest composer update I'm getting this error:

Argument 1 passed to GrahamCampbell\GitHub\GitHubManager::__construct() must be an instance of Illuminate\Contracts\Config\Config, instance of Illuminate\Config\Repository given, called in /Users/nicolaswidart/Sites/Homestead/PortfolioV2/vendor/graham-campbell/github/src/GitHubServiceProvider.php on line 85 and defined

Something I have to change?

Thanks,

Unable to use in Laravel Horizon

For some reason I get the following error when attempting to pass the client to a Laravel Job

Exception with message 'Serialization of 'Closure' is not allowed'

The event firing

$client = app(GitHubFactory::class)->make(['token' => $github->token, 'method' => 'token', 'cache' => true]);
            dispatch(new StoreUserGithubOrganisations($client, $event->user->id));

The actual job

<?php

namespace App\Jobs;

use Github\Client;
use Illuminate\Bus\Queueable;
use App\Models\GithubOrganisation;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class StoreUserGithubOrganisations implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $client;
    protected $user_id;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(Client $client, $user_id)
    {
        //
        $this->client = $client;
        $this->user_id = $user_id;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        //
        foreach ($this->client->me()->organizations() as $organisation) {
            GithubOrganisation::create([
                'github_login'      => $organisation['login'],
                'github_id'         => $organisation['id'],
                'github_node_id'    => $organisation['node_id'],
                'github_avatar_url' => $organisation['avatar_url'],
                'user_id'           => $this->user_id,
            ]);
        }
    }
}

I feel like this is something to do with the serialisation or lack thereof the client class and its sub classes. Is anyone able to confirm a workaround or if this is even possible?

issue create loops forever.

Hi Graham,

Thanks for the package. But i found a bug in your package.

if i do this in laravel.

public function pushGithub($fid)
{
    // Get the report data:
    $report = Errors::find($fid);

    // Set the push data:
    $push['title'] = "Platform issue nr. $report->id";
    $push['body']  = $report->melding;

    // Github push hook.
    Github::issue()->create('Tjoosten', 'handicap-manifesto', $push, 1);

    return redirect()->back(302);
}

The issue creation keeps on going. And spam the issue tracker on github.

Config setting to env setting.

I was wondering. Can we just set the config variables (Credentails github), To the default .env file in github.
Now there are need to fill in in the provided config file. So users can push their credentials by accident.

Error while installing from composer

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - knplabs/github-api 2.0.1 requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.0.0 requires php-http/client-implementation ^1.0 -> no matching package found.
    - graham-campbell/github v5.0.0 requires knplabs/github-api ^2.0 -> satisfiable by knplabs/github-api[2.0.0, 2.0.1].
    - Installation request for graham-campbell/github ^5.0 -> satisfiable by graham-campbell/github[v5.0.0].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.

Install Error at Composre about some package missed

error

☁  TranslatePlatform [master] ⚡ composer require graham-campbell/github
Using version ^5.1 for graham-campbell/github
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - knplabs/github-api 2.0.1 requires php-http/client-implementation ^1.0 -> no matching package found.
    - knplabs/github-api 2.0.0 requires php-http/client-implementation ^1.0 -> no matching package found.
    - graham-campbell/github v5.1.0 requires knplabs/github-api ^2.0 -> satisfiable by knplabs/github-api[2.0.0, 2.0.1].
    - Installation request for graham-campbell/github ^5.1 -> satisfiable by graham-campbell/github[v5.1.0].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.

mac php7.0.15

l4 publish asstes namespace not found

./artisan vendor:publish

[InvalidArgumentException]
There are no commands defined in the "vendor" namespace.

any suggestions or hints? running laravel 4.2

Error when using facade mocking

When using Laravel's native facade mocking GitHub::shouldRecieve()->... I get this error:

ErrorException: Declaration of Mockery_1_GrahamCampbell_GitHub_GitHubManager::__call($method, array $args) should be compatible with GrahamCampbell\Manager\AbstractManager::__call(string $method, array $parameters)

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.