M
M
MrSunny2016-12-14 23:01:41
symfony
MrSunny, 2016-12-14 23:01:41

How to save user input in Symfony Console?

Hello.
How can I store data entered by the user through the Symfony Console v3.2+ component?
This means some established solution, not a bicycle from file_put_content / file_get_content.
For example: the first command receives data about the connection to the database, tests it, saves it and transfers control to the second command, which receives (retrieves) the connection and works with it in the future.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2016-12-15
@prototype_denis

Commands must be atomic.
The problem of transferring the exhaust data of the first command to the second must lie on the shoulders of the one who uses it.
Use pipes
Temporary files
Although sockets ...
No need to call a command in a command.
First of all, puff is the best language and it dies the best of all. (For example, you will run into the limitation of child processes, loss of PID, and so on)
Secondly, it is architecturally more correct to use the unix approach and remove the data transfer process from the logic of the commands themselves. It's not their concern.
Thirdly, you can’t just take and save a database connection and transfer it to another process.
And yes... You should not make something like a finite state machine on Symphony commands, they are not designed for this.
In general, write down one command that will pull some model and forget about interface problems for business logic. (The command in this case is the interface for interacting with the application from the CLI. In this case, nothing will stop you from implementing the interface on http for this task)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question