T
T
tincap2019-01-27 18:49:51
Laravel
tincap, 2019-01-27 18:49:51

How to create your own component in Laravel?

I want to create a bot. I want him to be isolated from everything and be independent. Therefore, it is necessary that the configuration files lie in its folder.
I create my own component called Keitaro in the app/Components folder. He will be our bot.
The structure of the component itself will look like this

-app
    - Components
         - Keitaro
              - config.php
              - cookies.txt
              - Keitaro.php

The config.php file simply returns an array of settings.
1) How can I include a configuration file? I do n't really want to use the $config = require_once(config.php) construct
2) Am I using Laravel's capabilities correctly at all? Maybe there are special tools for creating such components?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2019-01-27
@tincap

Am I using Laravel's features in the right way at all?

Properly use composer and make your package.
https://laravel.com/docs/5.7/packages

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question