4
4
4ch232021-11-16 18:36:01
PHP
4ch23, 2021-11-16 18:36:01

How to store data in your composer package?

Where does composer packages store data, and do they store it?

There is a task - to create a package that will use and periodically update (from someone else's API) tabular data, the question arose - where to store this data? Force installation migrations to your database during installation? Use a file database of some kind? Nowhere can I get information about whether composer packages are allowed to expand in size during operation, for example (along with expanding the database)

I would be very grateful if you could help with the questions above, and even more so if you could suggest specific convenient tools (db, orm, resources about your composer packages, etc.)

Bonus question: Including as a dependency to a yii2 package - would it be too bad a tone?

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2021-11-16
@4ch23

The data should be stored outside the package directory, because the vendor is often wiped clean during deployment.
Therefore, they can lie anywhere, the package should make it possible to indicate this place.
Whether it will be a database or something else, the package must determine, and its users must implement this contract. You can make adapter packages (for mysql, for file storage, etc.) so that the user can choose how to store data.

Connecting as a dependency to a yii2 package - would it be too bad a tone?
If your package is supposed to be framework-independent, then yes, so-so solution. If it is closely related to Yii2, then why not...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question