Coder Social home page Coder Social logo

json-to-drupal-db's Introduction

json-to-drupal-db

A Simple php command line script to create Database Schema file ( ex: module.install ) for Drupal using JSON.

Note: this has been just written in few hours to make it bit more easy to define database schemas for drupal. Just shared on git hub for anyone else to use. The code might not be up to the proper standards since i did not want to spend too much time on it. Feel free to contribute if interested.

What is this?

It surely is not that hard to define table structures in the php file it self. but when it comes to multiple tables with more number of fields and definitions, it might be a waste of time to write the same words over and over ( ex: 'array' and '=>' signs ) all the time.

Instead, It will be very much easy to define a JSON file and convert it to the Drupal's Database Schema Format.

Usage

You need to simply run the file using CLI with the required Parameters.

php json2drupal.php --file table.json --table=your_table --module=module_name --output=output_file_name

Parameter Usage Description
--file Required json file with defined table structure for drupal. Ex: table.json
--table Optional if you want the table name to be filled in the code.
--module Optional if you want the module name to be filled in the code.
--output Optional to define the output file path/name to be generated.

To Do

  • Remove .php extension
  • Ability to Define Mulitple tables - Currently it only supports one table per execution. If you have multiple tables, you can define them in seperate JSON files and Generate the PHP file and later at them all together.
  • Boolean Fix - Currently the TRUE and FALSE values are generated with quotes. Feel free to fix that and contribute.
  • Parameter Validations - Not that important since this will be only used in a development enviroment. but if anyone cares, feel free to validate the parameters ( for ex: if json file provided exists )

Contributors

If anyone is interested in spending some time to make this better, which can save more time when generating schemas for drupal, feel free to contribute to this.

json-to-drupal-db's People

Contributors

nilansanjaya avatar

Watchers

James Cloos avatar  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.