Download the PHP package slavikme/slim-api-skeleton without Composer

On this page you can find all versions of the php package slavikme/slim-api-skeleton. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package slim-api-skeleton

Open Issues Stars on GitHub Forks on GitHub Sponsor by PayPal GitHub license

Slim API Skeleton

A skeleton project based on Slim Framework 2, which targets for developers to start an API application instantly.

NOTE: This is an alpha version and it is currently in a developmnet process

Contributions are welcomed!

Implemented

TODO

  1. Add authentication support based on API key with the following user information sources
    1. From Configuration File
    2. From Big Data/NoSQL records
  2. Add authorization support
  3. Add logging
  4. Add Caching mechanism
  5. Auto-doc generator

Recommendations

It is strongly recommended to install this framework on UNIX-based operating systems (Linux or Macintosh), as it is much easier and much faster to make everything work smoothly.
Of course you can make it work on Windows, but I would recommend to save your valuable time and prevent unnecessary headache.
In this documentation, I will explain how to make it work on UNIX-based system and not on Windows. If you still want to install it on Windows, I'm sorry, but you'll have to figure it out by yourself.
Note: You can always run a VM (Virtual Machine) with a Linux, using a VirtualBox or any other virtual machine to install a Linux OS. And then proceed with this documentation on your newly installed Linux on your VM.

Requirements

Installation

INCOMPLETE!

  1. Open a command line interface.
  2. Navigate to the path where you want to create the project directory.
  3. Run the following command:

    composer create-project slavikme/slim-api-skeleton
  4. Follow the instructions.
  5. Create a Virtual Host with the hostname slimapi.local and point the base directory to the public directory.

Usage

INCOMPLETE!

Just call any path defined in the routes.yml, with the token received from the Authentication process below, in the Authorization request header along with the phrase Bearer. For example:

GET / HTTP/1.1
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0aW1lIjoxNDM5MDQzMDkxLCJleHB0aW1lIjogMTQzOTA0NDI5MSwidXNlciI6eyJpZCI6IjEiLCJ1c2VybmFtZSI6ImVhc3Rlci1lZ2ciLCJyb2xlIjoiQURNSU4iLCJuYW1lIjoiQ29uZ3JhdHMsIE5vdyBZb3UgVW5kZXJzdGFuZCBUaGUgSldUIFByb3RvY29sIiwiZW1haWwiOiJnb29kQGpvYi5jb20iLCJzdGF0dXMiOiIxIiwibGFzdGxvZ2luX3RpbWUiOiIyMDE1LTA4LTA2IDE3OjEwOjA0In19.4YHynX_j2mhXLWGgLTHTf6IgY5HwHBIzl8mUqQa8vUw
Host: api.slim.local
Connection: close

Authentication

The authentication method implemented in this framework is JWT (JSON Web Tokens).
A special authentication route has been implemented and is ready to use out of the box.

Request

Use the route /auth with the method POST to authenticate by sending mandatory credentials username and password, and optional credential remember_minutes in the body of the request wrapped in form or JSON formats (both are supported equally).
The request body should be sent as follows:

JSON Format
{
    "username": "john",
    "password": "Snow123",
    "expiration": "45 minutes"
}

Note: JSON format requests must be sent along with the Content-Type: application/json header property in the request headers in order to make it work.

Form Format
username=john&password=Snow123&expiration=45%20minutes
Request Parameters

Response

The response depending on the request. If the authentication route has been requested without different, incorrect or invalid parameters, or without any username-password match in the tbl_user table, or user's status is equal or lower than 0, the response will be always 401 as an HTTP status code with the following JSON data in the body:

{
    "error": true,
    "msg": "Unauthorized access",
    "status": 401
}

Otherwise, the authentication should succeed with the response status code 200 and response body similar to the following:

{
    "error": false,
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0aW1lIjoxNDM5MDQzMDkxLCJleHB0aW1lIjogMTQzOTA0NDI5MSwidXNlciI6eyJpZCI6IjEiLCJ1c2VybmFtZSI6ImVhc3Rlci1lZ2ciLCJyb2xlIjoiQURNSU4iLCJuYW1lIjoiQ29uZ3JhdHMsIE5vdyBZb3UgVW5kZXJzdGFuZCBUaGUgSldUIFByb3RvY29sIiwiZW1haWwiOiJnb29kQGpvYi5jb20iLCJzdGF0dXMiOiIxIiwibGFzdGxvZ2luX3RpbWUiOiIyMDE1LTA4LTA2IDE3OjEwOjA0In19.4YHynX_j2mhXLWGgLTHTf6IgY5HwHBIzl8mUqQa8vUw",
    "status": 200
}
Response Referense

Authenticated Usage

TODO: Complete this section

Database

User Table

The following code used to create a new user table manually.

CREATE TABLE `tbl_user` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `username` varchar(50) NOT NULL,
    `password` varchar(255) NOT NULL,
    `role` varchar(50) NOT NULL,
    `name` varchar(255) DEFAULT NULL,
    `email` varchar(255) DEFAULT NULL,
    `create_time` datetime DEFAULT NULL,
    `update_time` datetime DEFAULT NULL,
    `status` tinyint(4) NOT NULL DEFAULT '1',
    `lastlogin_time` datetime DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `username_UNIQUE` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

All versions of slim-api-skeleton with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
composer/composer Version dev-master
slim/pdo Version dev-master
techsterx/slim-config-yaml Version 1.*
entomb/slim-json-api Version dev-master
needcaffeine/slim-api-extras Version ^1.0
slimcontroller/slimcontroller Version 0.4.3
slim/slim-skeleton Version 2.*
tuupola/slim-jwt-auth Version ^0.3.0
wp-cli/php-cli-tools Version ^0.10.4
incenteev/composer-parameter-handler Version ~2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package slavikme/slim-api-skeleton contains the following files

Loading the files please wait ....