The task sounds like this - to create a package (packege for Laravel), which during installation will generate the necessary tables in the database. How to do it?

I am new to web development, and therefore there is not even a common vision for where to dig, Internet searches have led to an understanding - that tables are created using migrations, migrations can be generated by a package, and run by hands from the command line ???. For example here http://jean179.ru/saite-vizitka-na-laravel-etap-5-sozdanie-tablic-v-baze-dannyx/

  • What do you mean by "package"? rpm- (deb-) package or something else? - aleks.andr
  • @ aleks.andr package in Laravel. This is a package that installs into this framework, and adds functionality to the site. accordingly, the user must take the package, set it to himself in laravel, and in the database all necessary tables used by the package should arise. - Mira

3 answers 3

I think you had a package meant to write your own set of classes that would include the Service Provider, routes, migrations, and the configuration file.

Everything is described in detail in the documentation.

If something is not clear, you can always look at the finished packages on github:

I would advise you to take a look at how packages such as entrust , laravel-sitemap , blog

You can also look at the articles that describe this question in detail. Laravel-5-package-in-10-easy-steps

    First you need to create a server-side (MySQL?) Script that creates the necessary structure — a database, tables, indexes — links, procedures — functions, triggers, users-passwords — rights. The same script should fill in the data with predefined tables (all sorts of reference books - countries, units of measure, etc.). Of course, all imaginable checks with the necessary branches and processing should be performed in the script.

    Next, you need a means of deploying the package to create a script that will receive information about the server, including information about connecting to it and authentication, connect to it, run the created script for execution and monitor its execution, and in case of problems, take the necessary actions to eliminate them. This script is run as part of the package installation process after all the prerequisite actions have been completed.

    This is a common technique. Depending on the specific means of deployment, changes and additions may be made to it.

    • yes, mysql. But is it really impossible to create a package that, regardless of the scripts on the server, will add the tables itself necessary for the package to work? I used to use Joomla - there you just put on a "clean" framework package and create all the necessary tables in the database. - Mira
    • The deployment tools for the Laravel expansion packs are unfamiliar to me. So I do not know the answer to this question. - Akina

    You need to make a .sql template file, then use PHP tools to write it into the database.

    Try first in phpmyadmin or in another program make all the necessary database structure, export to the sql format.

    Then read how to use PHP to fill in the database structure from the .sql file

    In general, in PHP everything is described in great detail, there should be no problems.

    The .sql template file should be located in the same place as all the raw materials for your task.

    • Creating a database in the application and creating migrations in the application is already done. When adding a package to this application, you need to create an additional table in the existing database. It seems dug in the office. the documentation laravel.com/docs/5.4/packages - Mira