Skip to content

This is a skeleton to built rest api with slim framework 3.

License

Notifications You must be signed in to change notification settings

aalfiann/slim-api-skeleton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slim-API-Skeleton

Version Downloads License

This is a skeleton to built rest api with slim framework 3.

Dependencies

  • Logger >> monolog/monolog
  • HTTP Cache >> slim/http-cache
  • ETag Middleware >> aalfiann/slim-etag-middleware

Installation

Install this package via Composer.

composer create-project aalfiann/slim-api-skeleton [my-app-name]

Getting Started

How to create new application

  • Go to modules directory
  • Create new folder my-app
  • To create routes, you should follow this pattern >> *.router.php
  • Done

Example

This is the my-app.router.php file

use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

// Route for /my-app
$app->group('/my-app', function($app) {

    // Show index page
    // Try to open browser to http://yourdomain.com/my-app/
    $app->get('/', function (Request $request, Response $response) {
        $data = [
            'welcome' => 'Hello World, this is my-app index page.',
            'message' => 'This is my first app rest api with slim-api-skeleton.'
        ];
        return $response->withJson($data,200,JSON_PRETTY_PRINT);
    })->setName("/");

});

Note:

About

This is a skeleton to built rest api with slim framework 3.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages