shiros / luna-web
Luna Module - Web
Requires
- php: >=8.2
- ext-openssl: *
- ext-sodium: *
- firebase/php-jwt: ^6.10
- shiros/luna: ^4.8
Requires (Dev)
- composer/composer: ^2.8
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-10-02 17:51:58 UTC
README
# Luna Module - Web A PHP **Web Module** designed for handling HTTP, routing, controllers, sessions, and authentication in the **Luna Framework**. **Robust**, **Flexible**, and **Developer-Friendly** - Simplifying web request handling in your PHP projects.[[TOC]]
ℹ️ About the Project
This project is developed in PHP 8.2 and is part of the Luna Framework ecosystem.
The Luna Web Module provides a structured way to handle routing, requests/responses, controllers, session management, and web authentication (JWT).
Detailed documentation is available in the Wiki: Luna Web Wiki
Key Features
- Routing and Dispatch: Handle web requests and map them to controllers.
- HTTP Abstractions: Request/Response utilities with sensible defaults.
- Controllers: Base abstractions for building application controllers.
- Session Management: Native PHP session handling utilities.
- Authentication (JWT): Decode and validate JWT for protected routes.
- Dependency Injection: Seamless integration with Luna’s DI for service wiring.
- PSR-4 Autoloading: Clean and autoloaded code structure.
- PHP 8.2 Features: Implements modern PHP features for clean, predictable code.
🔧 Dependencies
It uses PHP 8.2+, ensuring compatibility with modern features.
This module depends on the following:
- Luna Framework: The Luna framework's core. (MIT License)
- firebase/php-jwt for JWT handling. (BSD-3-Clause License)
- PHP extensions:
- openssl (JWT signing/verification algorithms)
- sodium/libsodium (modern crypto support; recommended for JOSE/EdDSA)
- Development tools:
Refer to the composer.json
file for additional details.
⚙️ Setup and Installation
To use the Luna Web module, follow the steps below:
Step 1: Install via Composer
Ensure Composer is installed, then execute the following in your root project folder:
composer require shiros/luna-web
Step 2: Autoload the Module
The module supports PSR-4 autoloading. If you're using the Luna Framework, it’s automatically available via the Luna module declaration. Otherwise, make sure to include Composer’s autoloader:
require 'vendor/autoload.php';
🚀 Usage Example
Refer to the official documentation for advanced examples and further details.
Typical integration points:
- Define routes under config and point them to your controllers (extending the module’s AbstractController).
- Use HTTP Request/Response abstractions within controllers.
- Configure authentication with JWT to protect specific routes while excluding public paths.
Example: Handling protected routes with JWT (conceptual)
<?php
// PHP
// In your route handling, JWTAuthenticationProvider will validate incoming Authorization headers,
// decode the token, and inject authentication data into the Request if access is granted.
📄 Testing
This project uses PHPUnit for testing, you can run the test suite as follows.
Step 1: Install development dependencies
Before running the test suite, ensure all project dependencies, including development dependencies, are installed. Use Composer to handle this:
composer install
This command will fetch all the required libraries and ensure your project setup is complete.
Step 2: Execute the Test Suite
Once dependencies are installed, you can execute the test suite using PHPUnit.
This ensures all the functionality of the framework is working as expected:
vendor/bin/phpunit --configuration phpunit.xml --colors=always
The test results will be displayed in your console. Colored output simplifies understanding the testing status:
- Green: Tests passed successfully.
- Red: Tests failed.
- Yellow: Warnings or skipped tests.
For more details on the tests, explore the /tests
directory. It contains comprehensive unit tests covering various
parts of the framework.
📃 License
This project is licensed under the MIT License, allowing you to use and modify this project freely.
See the LICENSE file for more details.
👨💻 Authors and Contributors
This project was created and is maintained by Alexandre Caillot (Shiroe_sama), with contributions from the community.
Authors
Contributors
We thank the following contributors for making this project better: