PHP Slim Micro Framework Starter
To create powerful web applications and APIs.

Follow these steps to create APIs.

 

  1. Clone the starter from GitHub repository using this command into your machine’s local server
    git clone https://github.com/vishalanandl177/php-slim-starter.git
  2. Edit the file src/config/config.php, set the server to development by setting the PHP constant
    define(“SERVER”, “DEVELOPMENT”);
    comment the produnction server
    //define(“SERVER”, “PRODUCTION”);
    and set the timezone, default is UTC 
    define(“TIMEZONE”, “UTC”);
  3. Configure the database connection. Edit the file src/config/connect.php

    if(SERVER ==’DEVELOPMENT’){
    define(“HOST”, “localhost”); // set the local host name for local machine
    define(“USER”, “”); // set the database username for local machine
    define(“PASSWORD”, “”); // set the database password for local machine
    define(“DATABASE”, “”); // set the database name for local machine
    define(“BASE_URL_STRING”, getBaseUrl());
    }

    if(SERVER ==’PRODUCTION’){
    define(“HOST”, “localhost”); // set the production host name
    define(“USER”, “”); // set the production side database username
    define(“PASSWORD”, “”); // set the production side database password
    define(“DATABASE”, “”); // set the production side database name
    define(“BASE_URL_STRING”, getBaseUrl());
    }

This starter has two APIs integrated. One for GET method and other is for POST method. In index.php file, in root directory, you can see the two APIs

$Rest->get(‘/get-call’, array($DeviceCtr, ‘getCall’));
$Rest->post(‘/post-call’, array($DeviceCtr, ‘postCall’));


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *