K
K
Kirill Gorelov2020-03-04 12:41:11
symfony
Kirill Gorelov, 2020-03-04 12:41:11

Updating a php application with symfony?

Hi guys.

The simplest explanation of my task can be described using cms as an example.
I am writing an application that you can download, put on your hosting and use.
This application is based on php framework symfony.

During the course of the application, updates may be released with updated tables in the database, or even new tables will appear.
And here I have a snag. In symfony, updating the entity table is done with a console command.
And how can you make the user simply click on one button and all other changes are pulled up and the database is updated.
Interested more in how to change the laid down table structure by the button or add a new one, without using the console?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladislav Lyskov, 2020-03-04
@Vlatqa

look aside https://symfony.com/doc/current/components/process.html

S
Sergey Romanov, 2020-03-04
@Serhioromano

All these migration systems are a headache. It’s worth it to fail in one place, and not when you can’t run a single migration normally.
I did this, when packaging the application, I make a snapshot of the base in JSON format. there data about fields, keys and relations. When installing, I make the same snapshot from the current database, look at the difference and automatically generate ALTER queries and bring the database to the required form.

F
Flying, 2020-03-04
@Flying

From Symfony's point of view, a console command is just a class that inherits from Symfony\Component\Console\Command\Command. Any console command is just running a class Symfony\Bundle\FrameworkBundle\Console\Application, as you can see in the bin/console.
Thus, nothing prevents you from "running a console command" by simply creating Console\Application and running the desired command in it, forming the correct input parameters.
Changing the database structure depends on how you manage it. Are you using Doctrine or something else? Do you use Doctrine Migrations or not? Without this information, it is impossible to give an exact answer. Most likely, in your case, it would be most logical to use Doctrine Migrations , because that's what they were created for.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question