pazuzu156 / AnubisBot

A Discord bot written in PHP
https://api.kalebklein.com/anubisbot/docs/
2 stars 3 forks source link

Call to a member function make() on null #24

Closed packtloss closed 6 years ago

packtloss commented 6 years ago

Hi There!

Was just trying out your lib. Tried both dev and master, same error:

me@discordbots:~/bots/anubisbot$ php cli run

`PHP Fatal error: Uncaught Error: Call to a member function make() on null in /home/dave/bots/anubisbot/vendor/illuminate/support/Illuminate/Support/helpers.php:382 Stack trace:

0 /home/dave/bots/anubisbot/core/Utils/Configuration.php(19): base_path()

1 /home/dave/bots/anubisbot/core/Utils/helpers.php(71): Core\Utils\Configuration->get('console')

2 /home/dave/bots/anubisbot/cli(13): config_get('console')

3 {main}

thrown in /home/dave/bots/anubisbot/vendor/illuminate/support/Illuminate/Support/helpers.php on line 382 me@discordbots:~/bots/anubisbot$`

Any insight?

pazuzu156 commented 6 years ago

That's quite an odd issue. Line 382 in illuminate's helpers.php file is the ending of a docblock.

The stack trace also seems centered around the config_get helper function. Comment out lines 13-18 and see if that error comes back. If you get an error run command not found it's cause it's not being loaded, since it's been commented out.

Also, you could try replacing the config_get helper function with loading in the Configuration class instead:

#!/bin/env php
<?php

require_once __DIR__.'/vendor/autoload.php';

use Symfony\Component\Console\Application;
use Core\Console\Console;
use Core\Utils\Configuration as Config;

$app = new Application();
$console = new Console();

// Get console commands
// $commands = config_get('console');
$config = new Config();
$commands = $config->get('console');

// Register all commands with Symfony's console app
foreach ($commands as $command) {
    $app->add($console->register($command));
}

// Run the app
$app->run();

This is also running on Windows. I'll run on Linux in a bit to make sure it's running fine, but a straight clone and using the code above both work on my end.

pazuzu156 commented 6 years ago

Alright, I ran it on Arch, and it ran as expected, without needing any changes. Make sure all the packages are installed correctly with Composer. I can give you my composer.lock file so you can install all instances of each package just as I have them

packtloss commented 6 years ago

Strange! 382 for me is this:

return app()->make('path.base').($path ? '/'.$path : $path); from the base_path function.

Sure, i can try the lock file. Thanks for your help!

packtloss commented 6 years ago

Tried your code above, and still get the same error.

me@discordbots:~/bots/anubisbot$ php cli2 run
PHP Fatal error:  Uncaught Error: Call to a member function make() on null in /home/dave/bots/anubisbot/vendor/illuminate/support/Illuminate/Support/helpers.php:382
Stack trace:
#0 /home/dave/bots/anubisbot/core/Utils/Configuration.php(19): base_path()
#1 /home/dave/bots/anubisbot/cli2(16): Core\Utils\Configuration->get('console')
#2 {main}
  thrown in /home/dave/bots/anubisbot/vendor/illuminate/support/Illuminate/Support/helpers.php on line 382
me@discordbots:~/bots/anubisbot$ uname -a
Linux discordbots 4.4.0-93-generic #116-Ubuntu SMP Fri Aug 11 21:17:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
me@discordbots:~/bots/anubisbot$

Composer seems happy with the install:

me@discordbots:~/bots/anubisbot$ composer update
Loading composer repositories with package information                                     Updating dependencies (including require-dev)         Nothing to install or update
Generating optimized autoload files
pazuzu156 commented 6 years ago

Hm, what support is that? Are you including a different version of Illuminate\Support? Looking at the path for the helpers.php file, it SHOULD look like this: /home/dave/bots/anubisbot/vendor/illuminate/support/helpers.php

I don't include Laravel's support module because DiscordPHP already requires that. Also, looking at the master branch for Laravel's source, line 382 is exactly the same as what I have locally. If you don't mind screen sharing with Discord, you can send me a message there: Anubis#8384

packtloss commented 6 years ago

I am not sure, it's what got pulled by composer.

My steps:

I provisioned a digital ocean droplet for testing (with a php7 lamp install). After a quick composer install i followed your instructions: composer create-project pazuzu156/anubisbot:dev-develop --stability=dev --prefer-dist composer update edit the .env file to add the token, php cli run

...and here we are! :)

I'll send you a message on Discord asap.

pazuzu156 commented 6 years ago

Problem solved. Updating composer fixed it