6

私はlaravelを始めたばかりで、これを理解したい...

アプリケーションにクラスがあるとしましょう:

namespace App\Tests;
class MyTest{

    public function sayHello($name){
        echo "Hello, $name!";
    }

    public static function anotherTest(){
        echo "another test...";
    }

}

ファサードとサービスプロバイダーを作成することの利点は、単に使用するだけではありません

use App\Tests\MyTest;

//... controller declarations here ....

public function someaction(){

    $mt = new MyTest();
    $mt->sayHello('John');

    //or
    MyTest::anotherTest();

}

//... etc...
4

1 に答える 1