Answer the question
In order to leave comments, you need to log in
How to correctly (and easily) integrate your php classes into Laravel application?
The project on Laravel 5.3 needs to integrate functionality for sending SMS (in my case, the ePochta service . There is an example of using classes on the site. It seems that the principle of operation and use is clear.
After downloading, we get several php files with different classes and an index file where all the others files (classes) are included.The
question is how to connect all this correctly in Laravel and use it in your controllers?
Include use, as I understand it is not correct.To connect classes, they use ServicePrivider, but how can I do all this, where to throw files, Don't know....
Answer the question
In order to leave comments, you need to log in
Hey!
Just the other day I was digging with this question :) Maybe I can help with something. You have several files, I have only one, but the essence will be clear.
My actions:
1) In the App folder, I created the Libraries folder, you can Classes, the main thing is for the speaker.
2) Registered in the namespace class: namespace App\Libraries;
3) In the controller, I used the following declaration: use App\Libraries\Sms;
And everything worked successfully :)
PS
Of course, it's probably better to write your Service Providers. If laravel complains that the class was not found:
1) Try to double-check all the names and declarations and the namespace carefully
2) The composer dump-autoload command may help
3) Write let in composer.json (link )
Here are some related links. I haven't tried it myself yet, but I'm putting it off for the future.
https://www.larashout.com/laravel-macros-extending...
https://laravel.demiart.ru/macros/
https://laravel.demiart.ru/laravel-sozdayom-svoi-s...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question