我正在使用Laravel 5.5并试图习惯按psr-2标准编写代码(刚刚开始学习).我用Quafoo QA分析我的所有代码,并逐步修复错误并记录它们.
通过使用外墙我得到这个错误"Avoid using static access to class".因为它我试图避免使用它们.
在我的控制器上我有这个代码:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Events\FileLoaded;
use Illuminate\Support\Facades\Input;
use Illuminate\Auth\Middleware\Authenticate;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use \Illuminate\Contracts\View\Factory as ViewFactory;
class LoadDataController extends Controller
{
public function index()
{
$viewfactory = app(ViewFactory::class);
return $viewfactory->make('LoadData/index');
}
//more code
}
Run Code Online (Sandbox Code Playgroud)
除了View Facade我也使用DB, Input, Validator and Storage
这是正确的方式,还有其他人吗?