Git Product home page Git Product logo

crudrestphp's Introduction

CrudRestPHP

skeleton of crud php (web service rest)

Description

This is an example of PHP Crud using a web service rest The authentication is present but non implemented... you need to add the check for username and password For the token we are used the web json token (see https://scotch.io/tutorials/the-anatomy-of-a-json-web-token) (now is implemented and tested ONLY GET and POST requests)

Requirements

  • PHP (tested php version 5.3.3)
  • PHP CURL support enabled
  • Apache rewrite module enabled
  • check if AllowOverride All is configured

#Files in the folder API This folder contain all implemented files

  • inc/config.inc.php ==> general configuration file
  • utils/ ==> directory that contain some utility file
  • .htaccess ==> apache file for manage the url rewrite
  • JWTGenerator.php ==> for manage the authentication and the token generation
  • WebServices.php ==> base of the web service implementation
  • index.php ==> contain the $endpoints array (list of enabled endpoints) and on which to redirect all calls using the .htaccess rules
  • CustomWS.php ==> manage the endpoints request

#Files in the folder testEndPoints Some script php for test the End-Points

#Installation The installation is really easy... but please follow these steps:

1 - Check if Apache rewrite module is enabled

2 - Check in the apache configuration if the document root (or documento root of the virtual host) have configured "AllowOverride All" (usually is configured "AllowOverride noneThe installation is really easy... please follow these steps: 1 - Check if Apache rewrite module is enabled

2 - Check in the apache configuration if the directive "AllowOverride All" is configured (for the "document root " or the "documento root" of the virtual host)... usually is configured "AllowOverride None"

3 - Check if the PHP CURL Support is enabled

4 - Copy the files in the document root or in a separate virtual host's document root (recommended)

5 - Configure the endpoints enabeled (see index.php file)

#Configuration and authentication

File inc/config.inc.php:

File index.php:

  • declare the list of endpoints using the array "$endpoints"

File CustomWS.php:

  • in the login method you need to add the check user/password (or other mode) for the authentication. Example: check in your users table

File .htaccess:

  • usually you don't need to change this file... this contain the rules for rewrite rules

#Next Steps

  • Implementation of the DELETE method
  • Add some authentication example

crudrestphp's People

Contributors

dannyrusy 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.