PHP Rest Api And Angular TypeScript Code Generator

Overview

Php Rest Api + Angular TypeScript Code Generator
The provided php scripts will generate CURD operations for the given MySql Database schema in Angular Type script and Php Rest Api. It creates the all the folder structure in Angular with required components, services, html files, css files, models, Modules, routing files for Angular. And All the required php scripts for the tables with create, update, delete, read, read-one methods and php classes for each table.
Click here for the example site created using this tool and with out writing a single line of code.
Features

  • It creates php classes (one for each table).
  • Creates methods(seperate php files) for CRUD operations (create, update, delete, read, readone)
  • Creates Typscript class for Services, Components, Models, Modules, Routes.
  • Creates Html Files, CSS files, for each table as forms.
  • Supports Pagination, sorting.
  • Primary key and Identity key handled.
  • Supports MySql Only.

Generated Code contains:

Php Rest Api folder structure it creates.
├─ api/
├─── config/
├────── database.php – file used for connecting to the database.
├─── objects/(for each table)
├────── “tablename”.php – contains properties and methods for “table” with database queries.
├─── “tablename”/(for each table)
├────── create.php – file that will accept posted data to be saved to database.
├────── delete.php – file that will accept a ID to delete a database record.
├────── read.php – file that will output JSON data based from “given table” database records.
├────── read_one.php – file that will accept ID to read a record from the database.
├────── update.php – file that will accept a ID to update a database record.
Angular TypeScript files

  • For display : Each table will have Component file, html file, css file.
  • For Add and Update : Each table will have Component file, html file, css file, service file and module file.
  • For Delete : Each table will have Component file, service file and module file.
  • Services : Each table will have a separate service file.

 
All the attached web screen generated by this tool. With out writing a single line of code.
**It needs primary key for each table. It supports only one primary key.
The code generation takes place in the server this script is only for taking the inputs and send it to server. The serve process the given data and generates the code which will provide the the download path.

Features

  • It creates php classes (one for each table).
  • Creates methods(seperate php files) for CRUD operations (create, update, delete, read, readone)
  • Creates Typscript class for Services, Components, Models, Modules, Routes.
  • Creates Html Files, CSS files, for each table as forms.
  • Supports Pagination, sorting.
  • Primary key and Identity key handled.
  • Supports MySql Only.

Requirements

For running the code.

Hardware Requirements

  • 1.6 GHz or faster processor.
  • 1 GB of RAM (1.5 GB if running on a virtual machine)
  • 50 MB of available hard disk space.
  • 5400 RPM hard disk drive.

Software Requirements

  • Visual studio Code for compiling and building Angular Code.
  • Any PHP editors or Notepad++.

For running PHP on Server
The PHP is the default scripting language implemented with the Apache or any other web server installed at the server where the php should be executed.
If your server supports PHP, then you do not need to do anything. Just create your .php files, put them in your web directory and the server will automatically parse them for you.

Instructions

Open the tool found under the downloaded zip file. ../CodeGen/CodeGen.html

Click on the DB Schema button.

Click on the “click here” link and follow the Instructions
1. Open the scripts folder.

2. Open the database.php file and change the host, username and password varailabes.

3. Upload the files to your server/virtual directory and run the Generate.php file.

4. Copy the generadted json data in the following Textarea. And click GetTablesSchema button.

Click on the GetDBSchema button.

After setting the required properties click on the generate button to generate the code.

The scripts will be processed and the above data will be displayed.
Click on the “Click here” link to download the generated code.
The generated zip file contains the read me file. 

Follow the instructions.

How to use the php Code?
Steps for using the scripts are given below.

Open the database.php form the generated files.
Replace the “hostName” in line number 4 with your Mysql hostname. If there is a port number include in it.
Replace “DBName” in line five with the your mysql db name.
Replace “UserName” with the username to connect to your DB.
Replace the “Password” in line number 7 with the password to connect to the DB.

Save the database.php file.
Upload all the files to webserver or any where you want to rum them.
How to run the Angular?
Steps for running the generated code “Angular” project.

Open the project in Visual studio code by pointing to Theam folder.
Open the Integrated terminal from View->Integrated Terminal.
Run the following command to install required the ngModules. Will install all the required packages.
npm install –save-dev @angular-devkit/build-angular
Open the file AppConstants from src->app->view-> AppConstants.ts.
Change the base url path to point to your hosted url. http://localhost:4200/api to your url.
In the Integrated Terminal  Use ng serve –open to run the project.
 

Related