How to add my own custom class in Laravel 5?

前端 未结 2 1618
离开以前
离开以前 2021-02-07 18:44

Ok, in laravel 4, if I want to add my own custom class, eg : library\\myFunction.php then I do the following steps :

  1. add \"myFunctions.php\" into
2条回答
  •  不思量自难忘°
    2021-02-07 19:35

    This should help you.

    FYI: Basically, you could create another directory within app, and then namespace your files in there as appropriate:

    app/CustomStuff/CustomDirectory/SomeClass.php.

    Then, within your SomeClass.php, make sure you namespace it:

    Now, you can access this class using the namespace within your classes:

    use App\CustomStuff\CustomDirectory\SomeClass;
    

提交回复
热议问题