byjg/resttemplate

This package is abandoned and no longer maintained. The author suggests using the byjg/rest-reference-architecture package instead.

ByJG's Reference Architecture project for RESTFul services in PHP with docker and database integrated

4.9.0 2023-05-24 19:53 UTC

This package is auto-updated.

Last update: 2024-01-06 06:29:12 UTC


README

Build Status Opensource ByJG GitHub source GitHub license GitHub release Scrutinizer Code Quality

This project is a boilerplate for create Rest Applications API Ready to Use with the best techniques to improve your productivity.

What is a PHP Rest Template?

mindmap
  (("Reference Architecture"))
    ("PSR Standards")
      ("WebRequests")
      ("Container & Dependency Injection")
      ("Cache")
    ("Authentication & Authorization")
    ("Decoupled Code")
    ("Database")
      ("ORM Integration")
      ("Migration")
      ("Routing")
    ("OpenAPI Integration")
      ("Rest Methods")
      ("Contract Testing")
      ("Documentation")
    ("Error Handling")

It is a PHP-based RESTful API template or boilerplate that aims to simplify the development process of RESTful web services in PHP. It provides a foundation or starting point for building APIs following REST architectural principles.

Using this PHP Rest Reference Architecture you can focus on the business logic of your application and not in the infrastructure as for example:

  • Rapid Development: By offering a pre-defined structure and essential components, the template can expedite the process of building RESTful APIs in PHP.
  • Standardization: The template promotes consistency and adherence to RESTful design principles, making it easier for developers to understand and collaborate on the codebase.
  • Customizable: Developers can modify and extend the template to fit their specific requirements, allowing for flexibility in implementing additional features or business logic.

Key features and components:

  • Uses OpenAPI specification for API documentation and endpoint creation.
  • Routing: Includes a routing system that helps map incoming HTTP requests to specific API endpoints or resources.
  • Middleware: It allows developers to add custom logic or perform operations before and after the request is processed.
  • Handling: The project offer utilities to handle and parse incoming requests, extract parameters, and handle request methods (GET, POST, PUT, DELETE, etc.).
  • Response Formatting: It provides mechanisms to format and structure API responses, including JSON serialization, error handling, and status codes.
  • Authentication and Authorization: The template include support for implementing authentication and authorization mechanisms to secure API endpoints using JWT.
  • Database Integration: It offers integration for connecting to databases, executing queries, and managing data persistence.
  • Error Handling: The project include error handling mechanisms to properly handle and format error responses.
  • Dependency Injection: It includes support for dependency injection and inversion of control (IoC) containers.
  • Testing: It includes support for testing the API endpoints and resources, including unit testing and functional testing.
  • PHP Standards: PSR-7 (Http Message Interface), PSR-11 (Container), PSR-16 and PSR-6 (Cache Interface) and others.

This project is not a framework. It is a template that you can use to create your own project. You can use the template as a starting point for your own project and customize it to fit your specific requirements.

Some Features Explained

This project install the follow components (click on the link for more details):

Getting Started

Here some examples of how to use the template:

Open source ByJG