Giter VIP home page Giter VIP logo

datex's Introduction

Datex

Simple command line tool for rapid development of database-related routines work (creating entity, form and model PHP classes/files) under PHP/Nette framework environment.

1 Installation

1.1 Install tool

In command line, type

>composer require spaceboy/datex

1.2 Copy script file

Copy file datex.php from

APP_ROOT/vendor/spaceboy/datex/bin/datex.php

to

APP_ROOT/app/bin/datex.php

1.3 Register service DatexModel

In APP_ROOT/config/services.neon add service into service list:

services:
	- Spaceboy\Datex\DatexModel(%datex%)

2 Configuration

2.1 Add configuration parameters

In APP_ROOT/config/services.neon add datex section into parameters:

parameters:
	datex:
		entity:
			namespace: App\Model\Entities
			path: app/model/entities
			template: templateEntity.phtml
		form:
			namespace: App\Forms
			path: app/forms
			template: templateForm.phtml
		model:
			namespace: App\Model
			path: app/model/models
			template: templateModel.phtml

2.2 Connect to database

Before first run, make sure your database connection is correctly set.

In database section of your config file (APP_ROOT/config/local.neon or APP_ROOT/config/common.neon) should be your DB connection described somehow like that:

database:
	dsn: 'mysql:host=127.0.0.1;dbname=my_database'
	user: db_user
	password: *****

Use script

In command line terminal, go to the APP_ROOT/bin directory and try very first run:

>php datex.php

If anything goes wrong, clear the cache and try again.

Works? Great. You can use the script in simple, classic way:

>php datex.php command [--parameter] [--switch]

Commands:

tables

>php datex.php tables

Writes list of accessible tables and views in database.

columns

>php datex.php columns --table table_name
>php datex.php columns -t=table_name

Writes list of columns of database table.

entity

>php datex.php entity --table table_name [--file path/to/EntityFile.php] [--overwrite] [--screen]
>php datex.php entity -t=table_name [-f="path/to/EntityFile.php"] [-o] [-s]

Creates PHP entity file based on colums of database table.

The file is placed in default directory declared in config section, or specified if file parameter of script.

If the target file already exists, script halts unless the ---overwite (-o) switch is used.

If the --screen (-s) switch is used, source code of PHP file is shown on screen and no file is written.

form

>php datex.php form --table table_name [--file path/to/EntityFile.php] [--overwrite] [--screen]
>php datex.php form -t=table_name [-f="path/to/EntityFile.php"] [-o] [-s]

Works same way as entity command, except that creates nette form file based on colums of database table.

model

>php datex.php model --table table_name [--file path/to/EntityFile.php] [--overwrite] [--screen]
>php datex.php model -t=table_name [-f="path/to/EntityFile.php"] [-o] [-s]

Works same way as entity and form command, except that creates PHP model file based on colums of database table.

datex's People

Contributors

spaceboy avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.