PHP Classes

How to Setup a PHP MVC Application Routes Extracted from Route Class Comments using Potato Service: Framework that extracts route details from classes

Recommend this page to a friend!
  Info   View files Documentation   View files View files (162)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2023-09-07 (15 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 44 This week: 1All time: 10,636 This week: 108Up
Version License PHP version Categories
potatoservice 1.0GNU General Publi...8.1Libraries, Design Patterns, PHP 8
Description 

Author

This package provides a framework that extracts route details from classes.

It implements the Command Query Responsibility Segregation pattern (CQRS) by parsing the routing information to route HTTP requests that match route pattern parameters defined in comments of the application route classes.

This framework uses PHP reflection to parse the application route classes comments and extract route details like the route:

- HTTP request type

- Name of the controller class and function name that will handle the routed request

- Required request headers

- Etc.

The framework can also validate the request parameters according to rules that applications define in map request classes.

Innovation Award
PHP Programming Innovation award nominee
September 2022
Number 5
PHP 8 implements the possibility to extract attributes defined in comments of PHP classes using PHP reflection support.

This package uses this possibility to implement an MVC framework that developers can use to configure HTTP request routes using route classes that comment attributes that define the details of the routing of HTTP requests to controller classes.

This way, developers can define the PHP application HTTP request routing configuration in the same class file that implements the routing code.

This possibility makes it easier to maintain complex PHP applications because it avoids the need to define routing PHP code in a separate file from the routing configuration.

Manuel Lemos
Picture of Maicon gonçalez
  Performance   Level  
Innovation award
Innovation award
Nominee: 3x

 

Details

PotatoService: API-Centric Framework

PotatoService is a comprehensive PHP framework meticulously crafted for API development. Infused with a plethora of features and streamlined methodologies, it stands out as a quintessential tool for creating scalable, reliable, and efficient APIs. Here's a dive into its core functionalities and design philosophies:

  1. Resource Management: At the heart of any RESTful API lies the principle of resource orientation. PotatoService offers a structured approach to map requests to specific resources, ensuring a clear and logical organization of endpoints.
  2. Dynamic Routing: Through the `#[Route]` annotation, the framework brings forth a flexible routing mechanism. This system is intricately designed to cater to various HTTP methods, establishing a foundation for a versatile API handling.
  3. Seamless Input Validation: APIs often act as gatekeepers, ensuring that only valid data interacts with the system. PotatoService's integrated validation attributes empower developers to define and rigorously check request inputs. This built-in robustness guarantees data integrity and security.
  4. Exception Handling with Clarity: In the realm of APIs, precise and informative feedback is paramount. PotatoService distinguishes between `BusinessException` and `ServerException`, delivering structured JSON responses. This nuanced approach ensures that clients receive clear and actionable error messages.
  5. Attribute-Driven Design: One of PotatoService's standout features is its rich attribute system. Attributes like `#[Cache]`, `#[Transactional]`, and various validations play pivotal roles in enhancing performance, ensuring data consistency, and maintaining data integrity.
  6. Interactive Console: A testament to its comprehensive nature, PotatoService boasts an interactive console. This tool is instrumental for backend operations, be it migrations, cache operations, or other housekeeping tasks, making API maintenance a breeze.
  • PHP Version Requirement: 8.1 or higher
  • Status: Alpha
  • Version: 0.1

Architectural Structure

The framework's architecture is divided into three distinct layers:

  1. Aplication Layer
  2. Domain Layer
  3. Infrastructure Layer

Configuration

  1. Project Settings: Modify the .env file to adjust your project settings. Path: infrastructure/.env -> $_ENV
  2. Dependencies: Set up and configure dependencies using composer. Path: infrastructure/composer.json

Wiki

  Files folder image Files  
File Role Description
Files folder imageapplication (1 file, 3 directories)
Files folder imagedomain (1 file, 2 directories)
Files folder imageinfrastructure (4 files, 7 directories)
Accessible without login Plain text file .htaccess Data Auxiliary data
Accessible without login Plain text file index.php Aux. Auxiliary script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:44
This week:1
All time:10,636
This week:108Up