garf / laravel-pinger

Ping search engines about website updates (weblog) in Laravel 5
MIT License
24 stars 7 forks source link

PHP - How to solve error - "Using $this when not in object context"? #14

Open novaidea opened 7 years ago

novaidea commented 7 years ago

require DIR . '../../vendor/autoload.php'; use Garf\LaravelPinger\Pinger; Pinger::pingAll('Tudam', 'https://www.tudam.pl/', '');

Fatal error: Using $this when not in object context in /home/ubers/vendor/garf/laravel-pinger/src/Pinger.php on line 99

Thank you

garf commented 7 years ago

Hello, As this is syntax for Laravel Facades, you can't use it like this in standalone context. You have to instantiate it with

$pinger = new Pinger();
$pinger->pingAll('Tudam', 'https://www.tudam.pl/', '');

But also you have to mock function config() as it exists only in Laravel. Please, check the constructor of the class. Best regards, Dinar.

garf commented 7 years ago

I just briefly checked the code, and unfortunately, you can't use this library without Laravel Framework.