Download the PHP package kristijorgji/db-to-php without Composer

On this page you can find all versions of the php package kristijorgji/db-to-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package db-to-php

db-to-php

A framework for automating PHP code generation for working with databases.

Many times we need data object classes corresponding to different database tables. For testing and populating the databases with dummy data we also require factories which generate dummy/fake data for those tables.

A lot of time is spent doing those tasks manually, so I decided to automate the process. Not only entities and factories are created by this library, but the original type is also detected and used in the classes and in the factory values generator.

For now the library supports only MySql as a database driver.

  1. Create entity classes based on your database tables.
  2. Create factories for automatic generation of entities with random data, or just random data for tables
  3. (Coming soon) Create repositories for writing/reading these entities
  4. (Coming soon) Working to support different database drivers aside from MySql

Table of Contents

Installation

Run the following command to initialize dbToPhp

This command will create in your project root folder the config file dbToPhp.cfg.php You need to edit that to your desired settings.

Config

The config and it's keys try to be as much self explanatory as possible. Example config:

You must setup the proper database credentials and driver (for now only MySql is supported). The

Example with :

Example with :

Usage

Generate Entities

Features

Generate Entities Instructions

First make sure to have setup correctly your database connection and credentials in the config file that is generated after the installation dbToPhp.cfg.php.

If you want the result code to be generated for php that supports typehinting and return types (also nullable like ?string) set typeHint key to true.

The other options are self explanatory. Change anything you like under the entities key in the config.

Below is shown only the part of the config for the entities generation, you can see a full configuration example in the config section.

Then just run from your terminal

Example entity generation

In my demo setup I only had selected the table below with the following MySql schema:

The generated entity class is given below (please note that class name, namespace, usage of annotations, typehinting, setters/getters etc anything can be customized in the configuration file):

https://github.com/kristijorgji/db-to-php/blob/master/docs/samples/entities/UsersDemoEntity.php

The name for the entity is UsersDemoEntity, but that can be customized and set in the config section 'entities'['tableToEntityClassName']

Generate Factories

Features:

(See example execution for demonstration)

Generate Factories Instructions

The config section for the factories is similar and self explanatory like the one for the entities:

After configuring the section to your preferences, execute the following to generate the factories:

Example factory generation

I am using as an example the same table that I used for generating entities.

The result factory is given below. As you can notice every data generated is detailed according to the table specifications.

License

db-to-php is released under the MIT Licence. See the bundled LICENSE file for details.


All versions of db-to-php with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
symfony/console Version >=3.3
vlucas/phpdotenv Version ^5.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kristijorgji/db-to-php contains the following files

Loading the files please wait ....