[英]Laravel 8: Undefined variable error message from custom Provider
我制作了一個名為TroneProvider
的自定義提供程序,如下所示:
use IEXBase\TronAPI\Tron;
class TroneProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
$fullNode = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.trongrid.io');
$solidityNode = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.trongrid.io');
$eventServer = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.trongrid.io');
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
//
}
}
並在providers
部分的app.php
注冊此提供程序:
'providers' => [
...
App\Providers\TroneProvider::class,
但現在我收到此錯誤消息:
ErrorException未定義變量:fullNode
那么那里出了什么問題呢? 但是package安裝成功。
我該如何解決這個問題?
只給你參考
class ContentController extends BaseController {
public $text = null;
public function getContent($description)
{
$content = Content::where('description', $description)->first();
return $this->text = $content->text;
}
}
像這樣使用它:
{{ App::make('ContentController')->getContent('starttext') }}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.