Download the PHP package mhasnainjafri/restapikit without Composer

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

Introduction

The mhasnainjafri/restapikit package is a Laravel-based toolkit designed to simplify the development of RESTful APIs. It provides a uniform structure for handling responses, exceptions, file uploads, authentication, and more. This package is ideal for developers looking to streamline API development while adhering to best practices.


Features


Installation

You can install the package via Composer:


Usage

Extending the RestController

To use the package, extend your controller from Mhasnainjafri\RestApiKit\Http\Controllers\RestController. This provides access to the package's built-in methods for handling responses, exceptions, and more.


Functionalities

1. Uniform API Responses

The package provides a consistent structure for API responses. For example:

Success Response

Paginated Response

If $data is paginated, the response will automatically include pagination metadata:

Alternatively, you can explicitly return a paginated response:


2. Exception Handling

The package simplifies exception handling by providing pre-defined methods for common scenarios:

General Exception

Validation Exception

Unauthorized Access

Server Error


3. File Management

The package includes utilities for file uploads, deletions, and URL generation.

Upload a File

Delete a File

Generate File URL


4. Caching API Responses

The cacheResponse method allows you to cache API responses for a specified duration.

Example:

1. Response Handling Without Controller Extension

The package provides a standalone API response helper for developers who prefer not to extend the RestController:

Success Response

Paginated Response

If $data is paginated, the response will automatically include pagination metadata:

Alternatively, explicitly return a paginated response:

2. Exception Handling

Simplified exception handling with pre-defined methods for common scenarios:

General Exception

Validation Exception

Unauthorized Access

Server Error

3. File Management

Built-in utilities for managing file uploads, deletions, and generating file URLs.

Upload a File

Delete a File

Generate File URL

4. Caching API Responses

Effortlessly cache API responses using the cacheResponse method or the API facade.

Example with $this:

Example with API Facade:

Clear Cache:


Notes

By offering both RestController methods and the API facade, this package empowers developers with flexible options to build robust APIs. Whether you prefer extending the controller or using standalone helpers, the toolkit adapts to your workflow.


5. Built-in Authentication

The package includes pre-defined routes and methods to simplify common authentication tasks, ensuring seamless integration into your application.

Available Routes

To enable authentication routes, include the following line in your api.php:

Customizing Routes

You can specify only the required routes:

Supported Authentication Routes

The following routes are available by default:


Postman Collection

A Postman collection is available to test the authentication endpoints. Download the Postman Collection here.


Authentication Methods

The package supports both Laravel Passport and Laravel Sanctum for authentication. To set up the desired method, run the following command:


Publishing Authentication Controllers

You can customize authentication controllers by publishing them to your project. Run the command below:

This will generate authentication controllers in the following directory:

After publishing the controllers, update the config/restify.php file to define the correct namespace for your authentication controllers.


6. HTTP Status Codes

The package includes a predefined API class with constants for common HTTP status codes:

Constants

APITOOLKIT provides various HTTP status codes as constants for convenience:


7. Custom Macros

You can define custom macros for reusable functionality. For example:

Example Macro:


Todo list

  1. Logger

Testing

To run the package's tests, use the following command:


Contributing

Contributions are welcome! Please see the CONTRIBUTING file for details.


Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.


License

This package is open-sourced software licensed under the MIT License. See the LICENSE file for more details.


Credits


This package boilerplate was generated using the Laravel Package Boilerplate.


All versions of restapikit with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.2|^8.3
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.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 mhasnainjafri/restapikit contains the following files

Loading the files please wait ....