Download the PHP package shangab/slim-swagger without Composer

On this page you can find all versions of the php package shangab/slim-swagger. 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-swagger

Slim Swagger Middleware

This is a Slim PHP middleware that automatically generates and serves Swagger (OpenAPI) documentation for your Slim PHP API routes. It supports dynamic route scanning, including GET, POST, PUT, PATCH, and DELETE methods, and generates detailed documentation without requiring external annotation libraries. This project was created for a project I am working on in php. I used to do backend with Python FatAPI or .NET, which both have swagger UI embeded in them, out of the box. However in php swagger it is tricky and time consuming.

I wanted the same automatic swagger in php in my new project but the easiest way I found is using external packages such as zircote/swagger-php which requires a lot of annotations if I got it right. I loved the fact that slim-php is light, powerful and scalable, Therefore, I started to build this middleware. The first version, tag, was built in a hurry in a single day, but the future roadmap will increase the middleware power and flexibility.

All the best wishes, use, recommend, star, fork, contribute, spread and enjoy it.

Features

Requirements

  1. php 8.2
  2. "slim/slim": "^4.9"
  3. "slim/psr7": "^1.5"

The classes to be used

We now have three classes:

  1. ShangabSlimSwagger The middleware for the swagger openapi and ui.
  2. ShangabJWTAuth The middleware for authenticated routes or group of routes.
  3. ShangabJWTUtil A utility class that have four public functions, to handle authorization using shangab/slim-swagger you should use this utility class:
    1. public function createToken($userData): string Given a user json object it will generates JWT token.
    2. public function verifyToken(): mixed This will verify the header Authorization bearer token and returns the user data or false if not authenticated.
    3. public function getTempPassword($length = 5): string This fuction will return a temporary password, default length is 5.
    4. public function getHash256($text): string This function takes any text and gives a 256 hash code.

Step 1: Installation

You can install this middleware in your Slim project via Composer from https://packagist.org/.

Step 2: How to use ShangabJWTUtil

Use this class to:

  1. Create JWT tokens for logged-in users.
  2. Verify that the user has valid tokens.
  3. Generate temporary passwords.
  4. Hash text as you see fit.

To use the ShangabJWTUtil class in your code, see below example:

2.1 To crate a JWT token:

2.2 To verify a JWT token, though the middleware does it for you, but f you want to:

2.3 To generate a temporary password:

2.4 To hash any text:

Step 3: How to use The Middleware

To use the middleware follow the code below, declare the ShangabSlimSwagger middleware and add it to your app in index.php: First list all the protected groups of endpoints or endpoints, then list the un-protected ones.

Please avoid using route names openapi and docs

I use these two routes and serve them before the $app routes, openapi returns the OpenAPI Specs, while docs route returns the swagger UI shown above.


All versions of slim-swagger with dependencies

PHP Build Version
Package Version
Requires slim/slim Version ^4.14
slim/psr7 Version ^1.7
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 shangab/slim-swagger contains the following files

Loading the files please wait ....